2010-11-22 112 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完全受支持。