我想在使用curl时收到移动版的页面。有没有办法在进行卷曲通话时发送自定义用户代理和自定义推荐人?如果答案是肯定的?
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);
答案 0 :(得分:2)
阅读文档:http://php.net/manual/en/function.curl-setopt.php
curl_setopt($ch, CURLOPT_REFERER, 'SomeReferrer');
curl_setopt($ch, CURLOPT_USERAGENT, 'SomeUA');