0
我一直在使用PHP SDK嘗試和照片發佈到測試用戶的活動在Facebook上:不幸的是如何將照片發佈到Facebook活動?
$c = 0;
$facebook->setFileUploadSupport(true);
while ($c < count($_FILES['file']['name'])) {
aFile = $_FILES['file'];
//..other code for ui and validity checks..//
$real = realpath($aFile["tmp_name"][$c]);
$attachment = array('message' => 'Test upload');
$attachment['image'] = '@'.$real; //also tried other keys. Please see below...
try {
$result = $facebook->api('/'.$event_id.'/photos?access_token='.$access_token, 'post', $attachment);
}
catch (FacebookApiException $e) {
echo('Could not post image to Facebook:'.var_export($e));
}
$c++;
}
,我得到的是錯誤:
'message' => 'An unexpected error has occurred. Please retry your request later.', 'type' => 'OAuthException', 'code' => 2
我一直在努力爲期兩天,這是我唯一上傳的代碼,所以我幾乎沒有超載Facebook(在我的情況下)試圖每隔一段時間發送一個500x500 jpg文件。
如果我將../photos?access_token=…
更改爲../feed?access_token=..
,則會發布文本,但不會顯示圖像。
我也試圖與處理圖像:
$attachment[basename($real)] = '@'.$real;
和
$attachment['source'] = '@'.$real;
和
$attachment['picture'] = '@'.$real;
所有沒有成功的本地文件。但$attachment
上的最後一個關鍵選項將允許一個帶有URL的帖子在隨機網站上顯示圖片。
有人可以告訴我,我是否正在'張貼到正確的開放圖形邊緣,或者如果我的代碼中存在處理圖像數據的錯誤?