I have been working on a facebook application which uses facebook graph API for authentication, recently facebook upgraded to IPv6 and my network does'nt support IPv6 so all of my calls started returning Host is unreachable error, I searched on facebook bugs and found that we can still use force the requests to facebook to use IPv4 using CURL CURLOPT_IPRESOLVE.
Now when I try to send request to Facebook Graph API using curl I get Notice: Use of undefined constant CURLOPT_IPRESOLVE - assumed 'CURLOPT_IPRESOLVE'
I want to know how can I enable support for this constant or how can I disable IPv6 support in php so that I can send request to Facebook Graph API using IPv4.
My code is
$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);
Thanks
Check you curl version
CURLOPT_IPRESOLVE is available since curl 7.10.8
Try this sample code to test
<?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;
}
FYI: http://gcov.php.net/PHP_5_3/lcov_html/curl/interface.c.gcov.php