我的代码:
function skype_resolver($username) {
$url = "http://skyperesolver.net/api/?isapi=true&get=skype&user=" . $username;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, true);
curl_setopt($ch, CURLOPT_PROXY, '177.12.236.216:80');
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return $output;
}
响应是:
Please Enable Cookies
我该怎么办? 在我的浏览器中,“http://skyperesolver.net/api/?isapi=true&get=skype&user=xxuser”的响应是:
190.255.121.56 Country: Colombia State: Bogota D.C. City: Bogotá ISP: COLOMBIA TELECOMUNICACIONES S.A. ESP VPN Dectected: No
感谢。
答案 0 :(得分:1)
您需要指定超时,因为代理很慢,请求需要时间,不需要任何cookie。
function skype_resolver($username) {
$url = "http://skyperesolver.net/api/?isapi=true&get=skype&user=" . $username;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // If url has redirects then go to the final redirected URL.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); //to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
curl_setopt($ch, CURLOPT_PROXY, '177.12.236.216:80');
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //The maximum number of seconds to allow cURL functions to execute.
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
}
答案 1 :(得分:0)
您需要指定代理端口:
curl_setopt($ch, CURLOPT_PROXY, "YOUR PROXY HOST");
curl_setopt($ch, CURLOPT_PROXYPORT, "YOUR PROXY PORT");