开发者

How can Android connect to Drupal service?

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 y开发者_StackOverflow社区ou 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜