How to code services in wordpress?

See am doing an android application,it has a web back end,am using wordpress as the web back end,but how can i code web services in wordpress?suppose i need to fetch some contents from database and pass it as json to android phones.So where should i place the php script or how can i do this?Is it possible to do web services using wordpress?

Here is the code:

Read More
$select_qry="select * from admin_details where username='$uname' and  password='$paswd'";
$result=mysql_query($select_qry);
$rows=mysql_num_rows($result);
if($rows>0)
$admin_arr=mysql_fetch_assoc($result);
json_encode($admin_arr);

How can i do this in wordpress?

Please help me..

Thanks

Related posts

Leave a Reply

1 comment

  1. You can follow these steps:

    1. Create a template with your PHP code
    2. Create a page. Let’s say the admin page is /my-service. Assign the template you created in step 1 to this page.

    Your adroid application can now call your wordpress service via the URL . mydomain.com/my-service.

    Notes:

    1. I assumed you meant a REST service.
    2. Creating web services in WP is possible, but not ideal because URL pathing would be very hard. i.e. WordPress wouldn’t know how to parse /player/id vs /player/id/status .. the first asks for all the player data, the second asks for a particular attribute of a player.