[development] providing example Services communication code for non-Drupal clients

Blake Senftner bsenftner at earthlink.net
Fri Feb 18 22:11:52 UTC 2011

Hey all,

I've developed a REST API using the Services module, and am in the process of writing client code examples. For API clients within a Drupal environment, the routine drupal_http_request() is a real gift. Something as simple as this:

$response = drupal_http_request($url, $headers, 'GET');
$data = json_decode($response->data);

gives clients my API responses in an easy to use array, with field names and embedded objects intact. 

For clients outside of a Drupal environment I am learning to use the libcurl php extension so I can provide them with a working example of how to talk to the API. However, I'm not finding any easy way to get the API responses from cURL into an easy to use structure, such as an array. The responses from cURL seem to always be a string, even when I request binary, and not an easy string to parse from looking at it. Maybe it's in some format I'm not familiar... it looks like there's some structure to it, but not clearly obvious, like JSON. 

What solutions in this arena are people using? With the popularity of APIs now, is everyone on this list using drupal_http_request() and not having to deal with cURL response parsing? 

bsenftner at earthlink.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110218/96e3fcf1/attachment.html 

More information about the development mailing list