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:
$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
You can follow these steps:
Create a template with your PHP code
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:
I assumed you meant a REST service.
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.
Related
I want to make my web service by using RoR and extend this service to mobile.
I searched how to connect RoR with android on google, However , The answer is building new ROR application with API only mode.
But I want to add API to the existing web application. How can i do this?
thank you!
The simple workaround is to create a api folder(api/v1 incase you are also planning versioning in future) in controllers,views & helpers.
Create a controller in controllers folder & the content would be like:
class Api::V1::TestsController < ApplicationController
def show
render 'show.json.jbuilder'
end
end
User Jbuilder to return response in json format.
There would be a json view api/tests/show.json.jbuilder.
The content of that file would be like:
json.equipment do
json.id #contact.id
json.name #contact.name
json.type #contact.type
end
and you are good to go.
I am new to Android and am confused on what to put for the URL fields when registering a new client with the Instagram API using their web form.
I'm specifically confused as to what to put for these fields:
Website URL
Valid Redirect URIs
I am making an Android app and it doesn't have a website, so what am I supposed to be putting here?
In my search for an answer that made sense to me, I found this: http://oferei.com/2013/06/serverless-instagram-authentication/
In short, this is what one would need to know about how to fill these fields if they are registering an app that does not have its own website:
Website URL: it doesn't matter what value goes here, I used localhost
Redirect URIs: The article above specifies a custom URI scheme, but this is not supported w/ the Instagram API anymore. However, I did see that also using localhost would work here as well in this article: http://jelled.com/instagram/access-token
Not sure if that is the best practice, but it is a way to get the client ID for an Android app.
I am starting to implementating a RazorPayment Gateway in one of my cordova application. and I am using this
https://github.com/razorpay/razorpay-cordova plugin. According to Razor Docs.
Step1: Payment is created when a user (the customer) fills up and submits the payment information and it is sent to the Razorpay API. : Successfully Implementaed
Step2:Authorized payment Details: Not Done
How can it possible using ajax. kindly tell me. event I completed my first step.
Can anyone share with me any knowledge how can I successfully completed this implementation.
After successful step 1:
you will get a [token] from razorpay.
Send the [token] to your server via ajax and save it in database.
The step 2: is done via the server using their SDK in php, java, etc. using the [token]stored in database.
usually step 2 is done with background jobs by the server.
Hope this helps
I need to use Imgur to upload images online using android eclipse. i created an account and was trying to register my application to get the client id and client secret. i reached here https://api.imgur.com/oauth2/addclient
I entered my Application Name as : com.nyp.assignment (is this just a name to it or we need to follow our package name? pls advise as well)
when i get to the callback url , i have no idea what to write for it. i've refered to here at https://api.imgur.com/oauth2 but still dont get it.
can someone list an example of a callback URL for Android? (Eclipse)
I'm trying to create users on a Ruby server (Heroku) from an Android app. I already have a users controller for creating users from the website. I am attempting to create a custom controller that responds with JSON to the Android app.
When I attempt to register from the app, logcat gives me the appname/public/500.html file from the server. When I run rake routes this is the output:
app_registration_create POST /app_registration/create(.:format) app_registration#create
But the app never reaches that route.
I have tried several different ways and this is the current set up of the routes file:
post 'app_registration/create'
I'm pretty sure the Android side is okay, but I could be wrong.
Any ideas? If more code samples are required, let me know.