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.
Related
I'm currently implementing a part of Xamarin app, which needs to open links in browser, after clicking the URL. I need to add support for http, https, ftp and ftps.
Our app uses .NET Standard 1.6 (Thus, can't use WebClient Class or FtpWebRequest class).
Device.OpenUri(uri) works fine with http and https in both iOS and Android. But only works with iOS for ftp links. With Android, app crashes with ftp links.
For file links with ftp, I managed to download files using FluentFTP (version="23.1.0").
Now I need to add support for ftp links with directory structures, to open that directory structure in the browser. (Like the default behavior of the Chrome browser)
I have tried:
Device.OpenUri(uri),
By creating an intent (Not working for ftp)
What you should be doing is something like below:
Create an interface for your Dependency Service for Android.
public interface IWebFTPClient<T>
{
Task<T> MakeFtpRequestAsync(); //Add Parameters if needed
}
Then call the depedency service method :
DependencyService.Get<IWebFTPClient<YourType>>().MakeFtpRequestAsync();
Note: Above code is an example piece and may need changes as per your needs
Since FtpWebRequest is available in native android, use it something like follows:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
Good luck
Revert if you have queries
I am creating a android application for eCommerce website.
Here at server side, i am using Shopify's eCommerce software.
So how could i call web service generated through Shopify's eCommerce software.
I have make research on it..
I found one link also link, but that demo is not running.
I need one simple demo where how can i use shopify api in android application
That Demo is working, I checked it today only. You can make a webview and use the Java/Android Library to make the call.
Use this part to make your call (for more details check demo code or api page):
JsonDirectoryCredentialsStore store = new JsonDirectoryCredentialsStore(getFilesDir());
Credential emptyCredential = makeEmptyCredential(shopname);
store.saveCredential(emptyCredential);
APIAuthorization auth = new APIAuthorization(emptyCredential);
URI authRequest = auth.generateAuthRequest();
Pass this authRequest to a webview and set a webviewclient to handle redirections by shopify.
You can then set up a callback to your localhost in the dev store you created and connect to that with the emulator loopback interface 10.0.2.2 from the app to test. At least that's the most convenient way I found.
I am trying to develop a Moodle Android app. I am using MoodleREST source code for my reference.Is there any other documentation on Moodle site which documents moodle core webservice functions with their required params.
I have found list of functions here http://docs.moodle.org/dev/Web_services_Roadmap but could not get proper documentation on how to call these functions with required params from mobile client using REST.
I am new to moodle and still learning it, so my question can be a little naive so please bear with it :)
This could be helpful http://docs.moodle.org/dev/Creating_a_web_service_client
And if you have some administrator access to Moodle, go to
yourmoodle/admin/webservice/documentation.php , or
Administration > Plugins > Web services > API Documentation.
There is API with documentation. (Dont know if there is better way though :/)
D.
AIUI you need admin to access the most comprehensive web service API, as described by #Dolfa. You'll need these docs and/or the source if you're developing against their REST API. The API docs are generated from the source, presumably so they accurately reflect the API in the installed version.
You could:
Browse the code on github
Clone the version you intend to program against so you can browse the code locally
Install it and give yourself admin so you can browse the API docs.
If you don't want to go through the hassle of setting up a local Moodle instance, you may be able to figure out a way to run the php that generates the docs.
Once you have a rough idea of an API call, you can often find out the details by looking at responses to command-line requests e.g.
curl 'https://your.domain/webservice/rest/server.phpmoodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=[your_ws_token]' --compressed | python -m "json.tool"
gives the response
{
"debuginfo": "Missing required key in single structure: userid",
"errorcode": "invalidparameter",
"exception": "invalid_parameter_exception",
"message": "Invalid parameter value detected"
}
indicating that the function requires a userid=[userid] argument.
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.
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.