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?

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

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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