How can Android connect to Drupal service? - android

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.

Related

Django channels API for android app

I am currently developing a server for android social network app. I am using Django and I need to add a real-time chat to it. I decided to use django-channels, but I am not sure how to use auth tokens coming to the server from the android to make the authentication in chat. Also, will django-channels even work properly in this situation or should I consider something else?
I would start be reading the following section of the Django channels documentation:
http://channels.readthedocs.io/en/stable/getting-started.html#authentication
As you can see you can use the session key from either the cookie, or from a GET parameter.
There are several decorators available to your web socket methods to retrieve session information.
These are:
#channel_session_user_from_http
#channel_session_user
#http_session
#http_session_user
etc...
By using these you can retrieve current user and other session details.
if you are going to use django-channels check this blog they wrote some decorators that do what channels sessions decorators(like those in #turbotux answer) do but for JWT.

How to save data online from all users using your app in android

I want to ask a question from my app users and get their answers but i don't know how to collect those data.
Please help me I need it.
You can use a form inside your application. And, ask users to fill that form. The forms needs to be connected to an database server. You may use 000webhost.com (free) to create your database. Just populate the table in database from the user response.
For this follow the following procedure:
1. Create a online database (000webhost.com)
2. Write php code to insert data into the database form and save that php on the file manager on server.
3. From android create a async task to execute that php.
4. Pass your parameter or user response as request attributes while executing the php.
5. php will save user's response on your server.
Now you can access that database from anywhere.
Note: This may require an internet connection in application.
Your question is much vague.
In general, app need to use HTTP POST with some standard data format as JSON/XML for communication between web server/client app.
This way client apps send/receive data in portable format across platforms &
implements UI/functionality as per platform standard e.g. Android or iOS
You could implement Google analytics in your app. Raise an event when you ask a question.

Store data in App Engine datastore from an Android app

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

Just cant integrate DRUPAL and ANDROID

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

How to connect to the drupal site with xmlrpc from Android?

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.

Categories

Resources