Posts tagged with facebook-ads-api

When I am trying to update the targeting of an AdSet, an error is returned. Session URL : https://developers.facebook.com/tools/explorer/321102689698722/?session_id=1408717453113278

{ "error": { "message": "Invalid parameter", "type": "OAuthException", "code": 100, "error_subcode": 3858082, "is_transient": false, "error_user_title": "Creative Must Provide enroll_status for Standard Enhancements", "error_user_msg": "This creative is eligible for Standard Enhancements, but enroll_status was not provided. Please choose whether you want to turn on standard enhancements or not. Learn more here: https://fburl.com/hyth50xo", "fbtrace_id": "AEIUzfYUlrFTKB8KAgPcVoz" } } 

But the enroll_status for Standard Enhancements is set in as OPT_IN for all the creatives inside the AdSet. Session URL : https://developers.facebook.com/tools/explorer/321102689698722/?session_id=425543010193929

[ { "degrees_of_freedom_spec": { "creative_features_spec": { "standard_enhancements": { "enroll_status": "OPT_IN" } } }, "id": "120208488275990030" } ] 

It's not an advantage+ ad. It's happening for most of the objectives.

I have two function. One is responsible for creating audience for the engaged page of Facebook and the other is for creating a custom audience for Instagram business account. I am using step functions to call my lambdas function. But whenever I try to create audience of Facebook and Instagram simultaneously, so I received an error of permission

No permission on event source: You do not have permission to create an audience on one or more event sources

But when I try to create a single audience for example just only for Facebook or just only for Instagram there is no error for the permissions but when I try to create audience simultaneously for the Facebook and for the Instagram business account I got this error

const createSocialAudience = async ({     name,     pageId,     adsAccountId,   } ) => {     if (!name || !adsAccountId || !pageId) {       throw new Error('Marketing API call missing required params');     }     const requestData = {       name,       description: 'Recent page visitors (from 360 days) visiting given page',       rule: {         inclusions: {           operator: 'or',           rules: [             {               event_sources: [                 {                   type: "page",                   id: pageId,                 },               ],               retention_seconds: 60* 60* 24 * 360,               filter: {                 operator: 'and',                 filters: [                   {                     field: 'event',                     operator: 'eq',                     value: 'page_engaged',                   },                 ],               },             },           ],         },       },       access_token: params.marketingApiToken,     };     const { data } = await httpClient.post(       `https://graph.facebook.com/v19.0/act_${adsAccountId}/customaudiences`,       JSON.stringify(requestData)     );     return data;   };   const createInstagramAudience = async ({     name,     igUserId,     adsAccountId,   })  => {     if (!name || !adsAccountId || !igUserId) {       throw new Error('Marketing API call missing required params');     }     const requestData = {       name,       description: 'Recent page visitors (from 360 days) visiting given page',       rule: {         inclusions: {           operator: 'or',           rules: [             {               event_sources: [                 {                   type: 'ig_business',                   id: igUserId,                 },               ],               retention_seconds: 60 *60 * 24 * 360,               filter: {                 operator: 'and',                 filters: [                   {                     field: 'event',                     operator: 'eq',                     value: 'ig_business_profile_engaged',                   },                 ],               },             },           ],         },       },       access_token: params.marketingApiToken,     };     const { data } = await httpClient.post(       `https://graph.facebook.com/v19.0/act_${adsAccountId}/customaudiences`,       JSON.stringify(requestData)     );     return data;   }; 

Expecting to create both of my audience at the same time for example I want two type of event_sources one for page of Facebook and one for ig_business

I've scoured through Graph API documents and their community forums, but I failed to find what I'm looking for.

I have page_id and post_id of a post that's an ad on Facebook, and I'd like to know the ad_account_id that is used to advertise it, or at least the campaign_id that the post belongs to.

I know the other way around that I could get post id from tracking_specs fields in act_<ad_account_id> endpoint, but is there anyway to get it backward?

Thank you in advance.

I am implementing the On Behalf Of flow as described here.

After Step 2's call to /<CLIENT_BM_ID>/access_token?scope=<scopes>&app_id=<APP_ID>&access_token=<PARTNER_BM_ADMIN_SYSTEM_USER_ACCESS_TOKEN>, I expect my app's system user Id to show up under the client's System Users (under Business Settings).

However, this never happens even though Step 2 returned the access_token as specified by the document.

How do I create a system user under the client's business manager?

When I call /me/accounts with the access token of the system user I created, it returns a page which I have access to (the one I connected in Step 4. However, making calls using the page_token retrieved result in the error:

"Cannot call API for on behalf of user :

The app I'm using is a test app.

My main question is how do I give my system user access to the client's assets?

I'm using official Facebbok API for getting ads with /ads_archive endpoint.

Example request:

curl -G \ -d "search_terms='oil'" \ -d "ad_reached_countries=['US']" \ -d "fields=id,ad_creation_time,ad_creative_bodies,ad_creative_link_captions,ad_creative_link_descriptions,ad_creative_link_titles,ad_delivery_start_time,ad_delivery_stop_time,ad_snapshot_url,age_country_gender_reach_breakdown,beneficiary_payers,bylines,currency,delivery_by_region,demographic_distribution,estimated_audience_size,eu_total_reach,impressions,languages,page_id,page_name,publisher_platforms,spend,target_ages,target_gender,target_locations" \ -d "access_token={ACCESS_TOKEN}" \ "https://graph.facebook.com/v19.0/ads_archive" 

Response does include Facebook Page ID. It also includes publisher_platforms field containing Instagram or/and Facebook. But no Instagram ID or username.

I find it weird, because web version of Ad Library (running under private API) shows that data. Example link

How can I get Instagram username using Official Ad Library API?

I've already passed all fields from Archived Ad Schema to my request.

Scraping private API seems hard, because it seems sensitive to proxies.