2009年11月19日星期四

two ways for Drupal to get remote site page

There are two ways to get the remote web page in Drupal:
1.

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);

Subsequent requests can then include the cookie by specifying the header.

2. use curl, php5-curl

sudo apt-get install php5-curl

The first way doesn't need to install curl library. While the curl may more flexible and powerful.



没有评论:

发表评论