Search code examples
phpfacebookfacebook-graph-apifacebook-marketing-api

Can't get Video details through Facebook Marketing API despite of having all necessary permissions


I try to get video details from my Creative through Facebook Marketing API.

Here is my code:

 Api::init(
     env('ADS_APP_ID'),
     env('ADS_APP_SECRET'),
     env('ADS_ACCESS_TOKEN')
 );

 $account = new AdAccount(env('ADS_ACCOUNT_ID'));
 $adcreatives = $account->getAdCreatives(array(
     AdCreativeFields::VIDEO_ID,
 ));

 $video_id = $adcreatives[0]->{AdCreativeFields::VIDEO_ID};

 $ad_video = new AdVideo($video_id);
 dd($ad_video->getSelf([AdVideoFields::THUMBNAILS]));

Also I have added necessary permissions in my App and double checked everything, I have:

  • pages_read_engagement - Standart Access
  • Page Public Content Access - Standart Access

Every seems fine and it should work, but I am getting this error:

FacebookAds\Http\Exception\AuthorizationException (#10) This endpoint requires the 'pages_read_engagement' permission or the 'Page Public Content Access' feature. Refer to https://developers.facebook.com/docs/apps/review/login-permissions#manage-pages and https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS for details.


Solution

  • After conversation with @CBroe in comments section, I can summarise steps which I did to avoid that error message:

    1. Navigate to Graph API Explorer
    2. Select your app in Facebook App select box
    3. Select User token in User or Page select box
    4. Add necessary permissions (in my case it was pages_read_engagement)
    5. Press Generate Access Token button
    6. Copy Token

    Additionally if you want token, which will not expire in couple of hours, you can generate it here Long-Lived User Access Token