我的代码可以检索我需要的所有内容(包含用户ID标记),但是从我的回复中删除,我发现我的object_attachment
正在创建此错误。
我的代码:
public function newPost(UserModel $user){
$this->fb->setDefaultAccessToken($user->accounts->where("network","facebook")->first()->access_token);
$message = 'Look at this amazing photo';
$photoUrl = 'http://weneedfun.com/wp-content/uploads/2016/11/Amazing-Pictures-4.jpg';
$photoRequester = $this->fb->request('POST', 'me/photos', ['url' => $photoUrl, 'published' => 'false']);
$photoResponseBodyId = $this->requestResponse($photoRequester)->getDecodedBody()['id'];
$friendsTagged = ['25235235', '52525222'];
$request = $this->fb->request('POST','me/feed', ["message" => $message, "tags"=> $friendsTagged, "object_attachment" => $photoResponseBodyId]);
$responseBody = $this->requestResponse($request)->getDecodedBody();
var_dump($request);
var_dump($responseBody);
die();
/*return $responseBody;*/
}
当我删除上述请求并将其保留为:
$request = $this->fb->request('POST','me/feed', ["message" => $message, "tags"=> $friendsTagged]);
它运作得很好。
我在做什么错误的堆垛机?
答案 0 :(得分:0)
好的,不要问我原因,但FB想要一个数组中的所有返回值(即使有1张图像。)
这是请求工作:
$request = $this->fb->request('POST','me/feed', [
'message' => $message,
'tags' => $friendsTagged,
'attached_media[0]' => '{"media_fbid":"'.$photoResponseBodyId.'"}'
]);