繁体   English   中英

Facebook Graph API无法访问

[英]Facebook Graph API Unreachable

我一直在开发一个Facebook应用程序,该应用程序将使用Graph API进行身份验证。该代码明天工作得很好,但现在突然之间我开始接收到Host无法访问的错误。 我使用的代码是:

$token_url = "https://graph.facebook.com/oauth/access_token?".
                "client_id=[client_id]".
                "&redirect_uri=http://www.next_big_website.com".
                "&client_secret=[client_secret]".
                "&code=" . $_GET['code'].
                "&scope=manage_pages,publish_stream,publish_actions,read_mailbox,email".
                "&response_type=token";
    $response = file_get_contents($token_url);

我收到的错误是:

警告(2):file_get_contents(https://graph.facebook.com/oauth/access_token?client_id= [client_id]&redirect_uri = http://www.next_big_website.com&client_secret= [client_secret]&code = somelong_and_ugly_code&scope = manage_pages,publish_stream,publish ,read_mailbox,email&response_type = token):无法打开流:网络无法访问[temp.php,第112行]

请帮助我,因为我不知道是什么原因造成的。

好的,我进一步研究并找到了解决方案,这是因为facebook试图强制使用IPv6,因为每当我的服务器尝试使用IPv4进行连接时,Facebook都会拒绝我的请求,tracert会跟踪到Facebook API服务器的路径,然后请求将被丢弃。

谢谢

通过使用修复它

 $url = ("https://graph.facebook.com/me/access_token?token");
    $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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM