Til*_*ain 13 curl facebook ipv6 facebook-graph-api
我一直在使用Facebook图形API进行身份验证的facebook应用程序,最近facebook升级到IPv6,我的网络不支持IPv6,所以我的所有调用都开始返回Host无法访问错误,我在facebook上搜索了bug,发现我们仍然可以使用CURL CURLOPT_IPRESOLVE强制对facebook的请求使用IPv4.
现在,当我尝试使用curl向Facebook Graph API发送请求时,我得到通知:使用未定义的常量CURLOPT_IPRESOLVE - 假设为'CURLOPT_IPRESOLVE'
我想知道如何启用对此常量的支持,或者如何在php中禁用IPv6支持,以便我可以使用IPv4向Facebook Graph API发送请求.
我的代码是
$url = ("https://graph.facebook.com/me/access_token?tokrn");
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$contents = curl_exec($c);
$err = curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
Run Code Online (Sandbox Code Playgroud)
谢谢
Ven*_*enu 12
检查卷曲版本
CURLOPT_IPRESOLVE自卷曲7.10.8起可用
试试这个示例代码进行测试
<?php
$version = curl_version();
// These are the bitfields that can be used
// to check for features in the curl build
$bitfields = Array(
'CURL_VERSION_IPV6',
'CURLOPT_IPRESOLVE'
);
foreach($bitfields as $feature)
{
echo $feature . ($version['features'] & constant($feature) ? ' matches' : ' does not match');
echo PHP_EOL;
}
Run Code Online (Sandbox Code Playgroud)
仅供参考:http://gcov.php.net/PHP_5_3/lcov_html/curl/interface.c.gcov.php
| 归档时间: |
|
| 查看次数: |
14140 次 |
| 最近记录: |