In the beginning I want to become authorised on a Drupal site, but I cannot connect with "system.connect", as a result I receive null. How can I do that? Thanks in advance.
From all what i know till now you need to have xmlrpc method library first in your project and then you can use xml rpc methods to connect to drupal site call methods and add paramteres
You will probably want to use services, it supports xmlrpc by default while Steps to make a mobile application using drupal as a back end or service deals with REST mainly the setup is virtually the same. You can change the JSON code from there to use the Apache XMLRPC android library.
The text below is related to xmlrpc.
You need to define your endpoint. Setup name, protocol (xmlrpc), allowed resources (nodes, users, comments, files, etc).
And enable "Session authorization" checkbox. Without it, all remote requests will be executed as anonymous user.
To authorize, you call "user.login" method with username and password arguments.
And if call is succeeded, store sessid and session_name values of returned method structure.
Then send value
session_name+"="+sessid
as cookie in all subsequent calls to identify the session.
Related
I want to make an android app which will login to my web application using rest API. In browsers we have a concept of cookie which servers use to identify/maintain session with the users.
In Android how would we accomplish it ? I heard that there is a concept of token which is sent by server in response(first time when credentials are validated) and Android app have to send it to server every time it tries to access a resource(protected). So, what is the better way of doing it ?
Do we need to validate the token again and again when the client requests for a resource ?
Honestly, I can't think of a better way of doing this. Token based authentication seems to be pretty standard when dealing with RESTful APIs. Is there any reason you can't do that?
If you don't want to change the server code, then this could be simulated by adding a cookie header to every request you send. But this is basically the same thing that you mentioned above, just not as clean.
And the browser is already sending a token to be validated again and again. Every request has a cookie header that gets validated through your web application on every request, so this isn't a big deal at all.
And, you don't need anything Android specific to accomplish this. In whatever http library you're using I'm sure there is a method you can called or something you can override in order to set custom headers. Use that to set either your cookie header or token header on every request that you need to make.
I have created an AppEngine connected Android application, and I'm trying to modify it to be able to store some user data on the server. I do not know what's the easiest way to do so, because I want it to be as simple as possible. I just want to store some basic data for every user. This data is: Name, Email, and some other Strings. I have created a form in the android side which will allow the user to type all the requested data, but I do not know how to send this information to the GAE server and store it in the datastore. I guess I will have to use a Servlet and some kind of RPC service to call the methods. I'm really lost because it is my first time doing this. I'm not experienced neither in android nor in web apps. I hope you can help me.
Update
Well, maybe I did not explain myself well. The system I've been asked to build consists on a web service that store your personal login credentials for most common sites (facebook, gmail, etc). Using a chrome extension, you ask the server for the credentials on the website you are navigating, and then the server asks to your phone for authorization. It will ask (do you give me permission to send your credentials to "some user"), and you have to ansewer yes or no and then the server will act in consequence. The point is that you have to store your credentials in the server in some way, maybe from the android app (which is what I was trying) or from somewhere else. I will also need authentication.
Pd: I use java for the server side.
Since you already started with AppEngine connected Android application, it makes sense to continue customizing it: App Engine Data Access: Adding Entities and RPC.
Update:
There are of course many ways to exchange data between client and server. The most simple would be a servlet handling GET and POST requests with some query parameters.
Also, most popoular lately is REST:
Android REST client: http://appfulcrum.com/2010/08/20/android-how-to-call-rest-service-using-asynctask/ (try using GSON instead to parse JSON)
Server: use a REST framework. My personal choice is RESTEasy. An example: http://ankiewsky.blogspot.com/2010/08/resteasy-on-googleappengine-corerest.html
Update 2:
The simplest possible way - making/handlin a simple POST request:
Android client - making POST request with parameters: http://www.androidsnippets.com/executing-a-http-post-request-with-httpclient
Server handling POST (or GET) and extracting parameters: http://www.exampledepot.com/egs/javax.servlet/GetReqParam.html
Find and follow thoroughly the Topic Index on this page. Gud luck
I'm building a data management system. In the end it will be sending SQLite data via http post method to an instance. I will not be building this web datadase and it wont be ready for some time. However I would like to continue my production of the app and get the http post methods set up correctly.
Is there a way to test http methods without already having a receiving client already set up?
Maybe a public client exists for this purpose?
I want to continue production (and testing) to the point so that when the web database is finally built all I need to do is essentially plug in the new url in my code. Is there anyway I can do that?
Thanks
You can ask it google
Example Henry's HTTP Post Dumping Server.
Stub the posting class, implementing an interface. Use it directly, or use something like Guice to inject it.
You can always set up a dev DB service, and should, but a stub may be sufficient for most of your dev.
I am using Drupal to create a web service for my android application.
I have basic understanding of Drupal like enabling modules , themes , configuring them ;
But this "Services" module is the one which I can not get in head.
I downloaded services 6.2 and enabled services module and node services module
Now when I navigate to site building -> services -> node.get
I get a form in which I can enter the node id and fields and this is working fine.
But I don't know how to get the response from android.
I have not yet enabled xmlRPC server.
I have enabled the anonymous user to visit the services page so that I don't need to get authentication or session id.
Basically I just want to see the response in my log cat in eclipse sdk for just node 1
and I will be set to go from that point.
Services module allow using remote protocols (xmlrpc, soap, rest, etc) to communicate third-party app with Drupal.
To use it, you need to define at least one endpoint. Setup name, protocol, allowed resources (nodes, users, files, comments, etc).
For example, define xmlrpc endpoint.
Then you can call it from xmlrpc client on Android.
xml-rpc exposes a set of remote methods, the most interesting are:
user.login - logs in user, it takes username and password as arguments
user.logout - logout
Node CRUD operations:
node.retrieve - retrieve
node.create - create a new node
node.update - update existing node
node.delete - delete node
node.index - get list of nodes
The same CRUD methods exists for other Drupal objects (files, comments, users, taxonomy_terms), only replace "node" to object name.
For example: "file.create" - create file, "file.index" - retrieve list of files, and etc
If you need to authorize, you need to call "user.login" first, and if call is succeeded,
store sessid and session_name values of returned method structure.
Then send value
session_name+"="+sessid
as cookie in all subsequent calls to identify the session. Also, you must enable "session authentication" checkbox in Drupal service endpoint configuration. Without it, all requests to endpoint will be executed as anonymous user.
To make your own xmlrpc service, you need to define hook_xmlrpc in your module, and expose a set of methods.
See the Services documentation at http://drupal.org/node/783722 and http://drupal.org/node/790416 for some examples to get you started. I find these give a good introduction on how to setup and use the Services module.
I'm not sure if this is what you are looking for, but you could use an HttpClient to access your service. See this answer for more help. Since I am not a Drupal expert, I'm not sure if you need to enable or disable xmlRPC since you have enabled these "Service" modules. With a little research (here) I did find some useful information that basically says enable xmlRPC on Drupal and import an XML-RPC client into your Android application to begin using it.
The question has been answered but I am adding what I found to be an excellent Video tutorial to integrate Drupal site with Android App.
http://www.youtube.com/watch?v=ezk_21sfEQM
I am writing an android program and I need to connect to the Drupal service to fretch the data or submit data. How can I do that?
Thank you very much!!!
I don't have a link available, but I know there was a fairly recent talk about using the Services module to integrate drupal with a mobile application. There is a featured article on the drupal website that discusses this a bit too.
I wrote an article with detailed instructions, about how to integrate Drupal with Android.
For connection to services, you can use xml-rpc.
You need xml-rpc client library for Android (for example, Redstone's lib with my modifications. You can find it at link, given at the end of my article about Drupal-Android integration).
xml-rpc exposes a set of remote methods, the most interesting are:
user.login - logs in user, it takes username and password as arguments
user.logout - logout
Node CRUD operations:
node.retrieve - retrieve
node.create - create a new node
node.update - update existing node
node.delete - delete node
node.index - get list of nodes
The same CRUD methods exists for other Drupal objects (files, comments, users, taxonomy_terms), only replace "node" to object name.
For example: "file.create" - create file, "file.index" - retrieve list of files, and etc
If you need to authorize, you need to call "user.login" first, and if call is succeeded,
store sessid and session_name values of returned method structure.
Then send value
session_name+"="+sessid
as cookie in all subsequent calls to identify the session. Also, you must enable "session authentication" checkbox in Drupal service endpoint configuration. Without it, all requests to endpoint will be executed as anonymous user.
If you need more details, you can find it here:
Drupal with Android integration: make posts and upload photos.
Sorry I don't know anything about Drupal services. But assuming they are a HTTP based services (e.g. REST service), Android uses the Apache HTTP library, see here for the HTTP docs.