2010-11-22 116 views
1

我的Facebook API存在问题。 这是我的代码:检索Facebook API上的access_token时出错

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($饲料); 此代码不起作用,* $ access_token *为空。为什么? 我有offline_perms和所有的墙壁读取... 我想做一个脚本来阅读我的状态(只是由我写!) 问题在哪里?有人能帮我吗? 我无法使用cURL,因为在我的服务器上它已停用,我不能要求启用它,因为它只是一个免费托管。是否有另一种方法来检索访问令牌? 非常感谢。对不起我的英文,但我不是。再见! :)

回答

1

我不能使用cURL,因为在我的服务器上它已停用,我不能要求启用它,因为它只是一个免费托管。

你不想听到它,但... 坏主意

1

你真的应该学习如何阅读错误信息,请仔细阅读:

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 

让我们把它分解:

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 

这是原因触发的错误,看着它,你可以看到,它说:

C中没有这样的文件或目录:\ Programmi \的appserv \ WWW \网站\人\上线19 content.php

的file_get_contents是无法看到被请求的文件,即:

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

所以如果file_get_content s无法看到facebook域名,我会建议获取启用了curl的服务器,或者至少file_get_contents完全受支持。