A Drupal 6 http client request is constructed so:
$http_results = drupal_http_request($url, array(), 'GET', NULL, 3);
Some URLs, however, require that a cookie is passed to each request to ensure that a correct response is issued. First, however, the cookie must be retrieved from an initial request.
$http_results = drupal_http_request($url, array(), 'GET', NULL, 3);
$cookie = $http_results->headers['Set-Cookie'];
$headers = array('Cookie' => $cookie);
$cookie = $http_results->headers['Set-Cookie'];
$headers = array('Cookie' => $cookie);
Subsequent requests can then include the cookie by specifying the header.
$http_results = drupal_http_request($url, $headers, 'GET', NULL, 3);
Mon, 09/28/2009 - 12:37
Hi, i'm trying to extract an xml from an api in which i have to login before get the xml file.
The url for login is like this: http://localhost:8080/path?username=username&password=pass
After that, the api redirects to http://localhost:8080/anotherpath where is the xml
So i tried to get the drupal_http_request(login_url) and then send the cookie in other drupal_http_request(redirect_url, header[cookie]) that i get but it doesn't work.
What i'm doing wrong?
»
Tue, 09/29/2009 - 12:16
You need to to analyse the data exchange to ensure that you are formatting your request correctly. Sometimes it takes perseverance to ensure that you have constructed your request correctly.
Use a protocol analyser to see what is going on. I use wireshark.
»
Post new comment