$header = array (
'User-Agent: Mozilla/50 (Windows NT 51) AppleWebKit/53736 (KHTML, like Gecko) Chrome/3301750146 Safari/53736'
);
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_TIMEOUT, 6); // 设置超时6秒
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 跳过SSL
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 跳过SSL
curl_setopt ($ch, CURLOPT_>
因为,PHP CURL库默认1024字节的长度不等待数据的返回,所以你那段代码需增加一项配置:
curl_setopt($ch, CURLOPT_:'));给你一个更全面的封装方法:
function req_curl($url, &$status = null, $options = array()){
$res = '';
$options = array_merge(array(
'follow_local' => true,
'timeout' => 30,
'max_redirects' => 4,
'binary_transfer' => false,
'include_header' => false,
'no_body' => false,
'cookie_location' => dirname(__FILE__) '/cookie',
'useragent' => 'Mozilla/40 (compatible; MSIE 60; Windows NT 51',
'post' => array() ,
'referer' => null,
'ssl_verifypeer' => 0,
'ssl_verifyhost' => 0,
'headers' => array(
'Expect:'
) ,
'auth_name' => '',
'auth_pass' => '',
'session' => false
) , $options);
$options['url'] = $url;
$s = curl_init();
if (!$s) return false;
curl_setopt($s, CURLOPT_URL, $options['url']);
curl_setopt($s, CURLOPT_>
因为,PHP CURL库默认1024字节的长度不等待数据的返回,所以你那段代码需增加一项配置:
curl_setopt($ch, CURLOPT_>
以上就是关于在 php curl返回全部的内容,包括:在 php curl返回、php curl如何直接转发当前php接收的headersget请求如何直接转发get参数post请求如何直接转发post参数、php curl选项列表(超详细)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)