tags:

views:

110

answers:

2

I need a multi-page drupal form that requests an external xml api and displays the data on the second page of the multi-page form.

I'm new to drupal and I've been reading advices on here and on drupal.org. I think I can either use the computed field on cck or I write an module to do this. I think I will do both, first using the computed field then write a module later on to get things running sooner.

I need some advice on how to create a computed field that calls an external api. Do I use curl or is there a drupal function that I can use? What drupal documents would help me and is it possible to provide a simple snippets to help me get started?

example api call https://my.example.com/XMLServices/xml?accessKey=&accountId=&form%5Fvar1=&form%5Fvar2=&form%5Fvar3=

Edit: I think its called REST api. I believe there are some modules that can help.

+1  A: 

There are some computed field snippets here

Curl should get data (if it is restful) but you will still have to parse the result.

Personally I would go down the route of using a custom module and hook_nodeapi or hook_form_alter, rather than a computed field, as it sounds like you are wanting some quite custom functionality.

Jeremy French
+1 - I'd recommend a custom module as well
Henrik Opel
+1  A: 

As for retrieving (and/or posting/putting) remote content from/to a REST interface (or anything else done via http), you should also take a look at the drupal_http_request() function. It can get you pretty far without having to go the curl route.

You can find a basic usage example in the aggregator_refresh() function in the aggregator module from Drupal core, where it is used to fetch RSS feeds.

Henrik Opel