2
我正在嘗試進行批量請求以在不同頁面上發佈獨特的照片。使用PHP SDK的批量請求和附加文件
爲此,我希望使用批量發佈請求來優化此過程。
我的代碼:
$facebook = new Facebook(array('appId' => myappId, secret => mysecret, 'cookie' => true, 'fileUpload' => true, 'domain' => $_SERVER['SERVER_NAME']));
$request[0] = array(
'relative_url' => 'facebookPageId1/photos'
'method' => 'post'
'body' => 'access_token=page_access_token_1&message=my_message&attached_files=' . basename($picture));
$request[1] = array(
'relative_url' =>'facebookPageId2/photos'
'method' => 'post'
'body' => 'access_token=page_access_token_2&message=my_message&attached_files=' . basename($picture));
$file[basename($picture)] = '@' . realpath($picture);
$batch = json_encode(array_values(requests));
$params = array('batch' => $batch);
$params = array_merge($params, $file);
$facebook->api('/', 'POST', $params)
現在,當我運行這段代碼我得到了我的兩個請求以下的輸出:
'{"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}'
那麼,有什麼問題呢?
我設置的FileUpload在真正對我的Facebook對象,我試圖張貼在網址「PAGEID /照片」採用了經典的請求的照片,它的完美。但女巫一批請求,我總是有同樣的錯誤。
感謝您的幫助。
編輯:好吧,我得到了我的錯誤,我的要求是錯誤的:
$request[0] = array(
'relative_url' => 'facebookPageId1/photos',
'method' => 'post',
'body' => 'access_token=page_access_token_1&message=my_message',
'attached_files' => basename($picture)
);
$request[1] = array(
'relative_url' =>'facebookPageId2/photos',
'method' => 'post',
'body' => 'access_token=page_access_token_2&message=my_message',
'attached_files' => basename($picture)
);
但現在我得到了以下錯誤:
{"error":{"message":"File picturename.jpg has not been attached","type":"GraphBatchException"}}