I try to publish a post with multiple videos and photos by using the PHP SDK. I uploaded videos and photos using batch request and got the id. Then I pass the media ids along with post data using attached_media. Things work fine for single or multiple photos. But not for a single video or multiple videos. I got this error: "Graph returned an error: (#10) Application does not have permission for this action" whenever ids of videos are included in attached_media.
Here is the code that I used:
$fb = $this->init(); try{ // Returns a Facebook\FacebookResponse object
$publishData = [ 'message' => $post['content']];
if(count($media_ids) > 0){
$publishData ['attached_media'] = [];
foreach($media_ids as $key => $media_id){
array_push($publishData['attached_media'],'{"media_fbid":"' . $media_id . '"}');
}
}
$response = $fb->post(
'/me/feed',$publishData
,
$accessToken
);
}
catch(FacebookResponseException $e){
echo 'Graph returned an error: ' . $e->getMessage();
echo $e->getTraceAsString();
exit;
}
catch(FacebookSDKException $e){
echo 'Facebook SDK returned an error: ' . $e->getMessage();
echo $e->getTraceAsString();
exit;
}
$graphNode = $response->getGraphNode();
Is there anyway to solve this. Thank you.