开发者

Failed to open stream when reading contents from URL

开发者 https://www.devze.com 2023-01-12 07:30 出处:网络
file_get_contents() is returning \"failed to open stream\" when I call it on a Facebook access_token URL.

file_get_contents() is returning "failed to open stream" when I call it on a Facebook access_token URL.

Warning: file_get_contents(https://开发者_开发知识库graph.facebook.com/me?access_token=xxxxx) [function.file-get-contents]: failed to open stream: No such file or directory in /home/manorlog/public_html/index.php on line 109

If I try to manually hit the Facebook access_token URL it shows me my persional details

I have also tried this code and verified it works:

$foo = file_get_contents('http://google.com');
echo $foo

Anyone have any ideas why file_get_contents() is failing with the Facebook access_token URL?


First thing I notice is the missing quotes around your facebook url. Also, php has the setting allow_url_fopen, which controls if you are allowed to open urls as files. But your example with Google suggests, that at least this works. Another thing I noticed: maybe you don't have SSL-support compiled into PHP? Sorry, mostly guesswork.


Your accesstoken might be expired. Or invalid.

<?php
$access_token = '';
$foo = file_get_contents("https://graph.facebook.com/me?access_token=".$access_token."");
echo $foo;
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消