skip to Main Content

I’ve been roughly trying for 10 hours now to set up facebook to create custom audiences via POST REQUEST

What I have so far is , I created an app, an access token with some permissions (as stated in the fb docs) which would be:

  • read_insights ads_management ads_read public_profile

My Goal is: Creating a Custom Audience per API Call , the Data provided for the user comes from me , included in the api call as a JSON object

So i am making the GET Request like this

        $client = new Client();

    $response = $client->request('GET','https://graph.facebook.com/v5.0/act_<act number>/customaudiences',[
        'query' => [
            'name' => 'my custom audience',
            'subtype' => 'CUSTOM',
            'customer_file_source' => 'USER_PROVIDED_ONLY',
            'access_token' => '<accesstoken>',
        ],
    ]);

and it returns 200 ok , “{“data”:[]}”

So it seems that the custom audience has not been created (wanted to create an empty one for now) , what am I doing wrong?
Thanks for the help.
Greetings

2

Answers


  1. The Graph API documentation states that the API call has to be a POST request but you are making a GET request here.

    Try this:

    $client = new Client();
    
    $response = $client->request('POST','https://graph.facebook.com/v5.0/act_<act number>/customaudiences',[
        'query' => [
            'name' => 'my custom audience',
            'subtype' => 'CUSTOM',
            'customer_file_source' => 'USER_PROVIDED_ONLY',
            'access_token' => '<accesstoken>',
        ],
    ]);
    
    Login or Signup to reply.
  2. Sapnesh, a thing to keep in mind that to create Offline Custom Audiences you have to first accept terms & conditions in Business manager to be able to do it. Before that you will be getting en error.

    Still, you error looks like you access token has insufficient permissions for audience creation. You can make first and Access token with full permissions to debug your requests and get to successful Audience creation and then issue limited access token only for that purpose if you need it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search