How to aduser with admin access while creating ad account facebook marketing api

前端 未结 1 863
悲哀的现实
悲哀的现实 2021-01-21 06:01

I am trying to create ad account in Facebook business manager via Facebook marketing and graph API using following code.

$attachment =  array(\'access_token\'            


        
相关标签:
1条回答
  • 2021-01-21 06:33

    Once the ad account is created, you'll need to make another call which will add the user with the required permissions.

    $attachment =  array(
        'access_token' => $this->accessToken,
        'business' => '<business_id>',
        'user' => '<user_id>',
        'role' => 'ADMIN'
    );
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$this->apiVersion.'/act_<AD_ACCOUNT_ID>/userpermissions');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
    $result = curl_exec($ch);
    $dcde = json_decode($result);
    curl_close ($ch);
    
    0 讨论(0)
提交回复
热议问题