1

I'm trying to get data out of an .NET Web API into drupal in code. Everyting is working when the Web API is not secured/authenticated using the code below.

$request = drupal_http_request('http://10.129.132.253/StappAncor/api/person/1');
$items = drupal_json_decode($request->data);
dpm($items);

But when I publish the Web API onto my live server (behind authentication and https), I can't use the default drupal function drupal_http_request because it only supports basic authentication.

Any suggestions? Are the other WebClients I can use?

  • Problem is in https or in authentication? – Mołot Jun 15 '15 at 9:36
1

When Drupal requests are not enough, I found cURL a good way.

PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.

It can either be used directly, or via cURL HTTP Request wrapper module.

This is a module intended for developers, as it provides just one API to call: chr_curl_http_request() (use curl_http_request() for versions 1.5 and earlier).

The function chr_curl_http_request() is an alternative implementation of Drupal core function drupal_http_request() using cURL. The function intends to be backwards compatible with drupal_http_request(), by accepting the same parameters in the same form and by returning the response in the same format.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.