0

我想在使用 ccurl 时接收移动版页面。有没有办法在进行 ccurl 调用时发送定制的用户代理和定制的推荐人?如果答案是肯定的怎么办?

function get_data($url) {
  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}

$page="http://www.somesite.com";
$input = get_data($page);
4

1 回答 1

2

阅读文档: http: //php.net/manual/en/function.curl-setopt.php

curl_setopt($ch, CURLOPT_REFERER, 'SomeReferrer');
curl_setopt($ch, CURLOPT_USERAGENT, 'SomeUA'); 
于 2013-02-09T06:37:49.423 回答