开发者

Error retrieving access_token on Facebook API

I have a problem with the Facebook's API. This is my code:

    require_once "facebook-php-sdk/facebook.php";

    $facebook = new Facebook(array(
     'appId'  => '(the 开发者_开发技巧app code)',
     'secret' => '(the secret code)',
     'cookie' => true,
    ));     

    $access_token = $facebook->getAccessToken();
    $uid = "(my user id)";

    $feed = $facebook->api("/{$uid}/feed?access_token={$access_token}&limit=5");

print_r($feed); This code doesn't work, the *$access_token* is empty. Why? I have the offline_perms and also all perms for read the wall... I wanna make a script for read my status (just writed by me!) Where is the problem? Can someone help me? I can't use cURL because on my server it's deactivated and I can't ask to enable it because it's just a free hosting. Is there another way to retrive the access token? Thanks so much. Sorry for my English, but I'm not it. See you! :)


I can't use cURL because on my server it's deactivated and I can't ask to enable it because it's just a free hosting.

You don't wanna hear it but ... Bad idea.


You should really learn how to read error messages, Please read it carefully:

Warning: file_get_contents(https://graph.facebook.com/oauth/authorize?client_id=xxx&redirect_uri=http://localhost/site/others/content.php) [function.file-get-contents]: failed to open stream: No such file or directory in C:\Programmi\AppServ\www\site\others\content.php on line 19

Lets break it down:

Warning: file_get_contents(https://graph.facebook.com/oauth/authorize?client_id=xxx&redirect_uri=http://localhost/site/others/content.php)

This means that this functions has triggered a Warning

[function.file-get-contents]: failed to open stream: No such file or directory in C:\Programmi\AppServ\www\site\others\content.php on line 19

This is the reason the error was triggered, looking at it you can see that it says:

No such file or directory in C:\Programmi\AppServ\www\site\others\content.php on line 19

file_get_contents is unable to see the file being requested, ie:

https://graph.facebook.com/oauth/authorize?client_id=xxx&redirect_uri=http://localhost/site/others/content.php

So if file_get_contents is not able to see the facebook domain, I would recommend getting a server where curl is enable or at least the file_get_contents is fully supported.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜