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.

Share:
Share on Facebook0

Share on LinkedIn0Tweet about this on TwitterShare on Google+0Buffer this pageDigg thisShare on Reddit0

Leave a Reply

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

Most Popular Posts

How to develop Magento Extension

Posted on 4 years ago

Bhumi

Synchronous Up & down Slider with jQuery

Posted on 5 years ago

Bhumi

How to use NoSQL and MongoDB

Posted on 5 years ago

Bhumi

What is Wpautop() function in WordPress

Posted on 2 years ago

Bhumi

How to Use the HTML5 Full-Screen API

Updated 17 years ago

Bhumi

What are Lambdas and Closures in PHP?

Updated 17 years ago

Bhumi

MySQL REGEXP Operator

Updated 17 years ago

Bhumi

HTML5 Geolocation API with Example

Updated 17 years ago

Bhumi

Overview of Views in MySQL

Updated 17 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 2 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 3 years ago

Bhumi