Back to Top

How to use Web service in WordPress?

Webservice in Wordpress

Here I am going to explain new article about how to call web service in WordPress.

Web services are useful to retrieve your contents from PHP to mobile devices.whenever you want to get data into mobile from PHP and your PHP is using WordPress for a web application, you also have to follow rules of WordPress and PHP.

Well, here I am going to write one basic web service in WordPress and web service is about to login into the mobile app using WordPress username and password.

Must Read: GoTo statement in PHP

So, let’s understand code written below:

First of all, create one folder, let’s say “webservices” into your root of WordPress or into your theme folder.

Next create one file say “login.php” and place below code into it.

Here, when you pass data and call this URL from mobile app,return data with encoding as JSON and into an array web data because function decode variable web data and using it to check into WordPress that valid username and password entered by user.

In above code, I am passing status and message with callback because when you are calling from mobile, you need to use JSONP data type which require callback to get return data.

That’s it. Hope this is useful to write web services into WordPress. To check your raw web service, you can use advanced rest client extension in chrome.

Hope this helps someone else out.As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

Django Tutorial for beginners

Posted on 1 year ago


How to call Remote URL in jQuery Ajax?

Posted on 4 years ago


How To Reset resourceID in MODx

Posted on 5 years ago


MySQL FLUSH Commands

Posted on 6 years ago