我寫了一個函數將照片張貼到用戶牆,它會引發以下異常發佈照片至Facebook引發的異常
Fatal error: Uncaught OAuthException: A user access token is required to request this resource. thrown in C:\xampp\htdocs\upd8r\application\helpers\base_facebook.php on line 1039
這是我失去了我的代碼 - 什麼?
function facebook_img_post($fb_id,$data){
$this->load->helper('facebook');
$this->load->model('mmaster');
$globalSettings = $this->mmaster->getGlobalSettings('1');
// Create our Application instance.
$this->facebook = new Facebook(array(
'appId' => $globalSettings['facebook_id'],
'secret' => $globalSettings['facebook_secret'],
'cookie' => false
));
$this->facebook->setFileUploadSupport(true);
$this->facebook->api("/".$fb_id."/photos",'post', array(
'message'=> $data['message'],
'source' => $data['source']
)
);
//new fb post
}
更新
這是顯示所有的權限,註冊用戶請求
$data['loginUrl'] = $this->facebook->getLoginUrl(array('scope' => 'read_stream,publish_stream,status_update,offline_access'))
更新2
我換了API並嘗試過的鏈接與捲曲有更多的控制,顯然我需要一個用戶訪問令牌,甚至雖然我正在檢索和使用應用程序訪問令牌 - 顯然有兩個不同的。
類似問題這一個:[http://stackoverflow.com/questions/4662118/facebook-api-error-uncaught-oauthexception-error-validating-access-token][1] [1] :http://stackoverflow.com/questions/4662118/facebook-api-error-uncaught-oauthexception-error-validating-access-token – Robert 2011-12-13 18:56:55