繁体   English   中英

如何在创建广告帐户facebook营销API时使用管理员访问权限

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

我正在尝试使用以下代码通过Facebook营销和图形API在Facebook业务经理中创建广告帐户。

$attachment =  array('access_token'      => $this->accessToken,
                        'name'           => $associative_arr['name'],
                        'currency'       => $associative_arr['currency'],
                        'timezone_id'    => $associative_arr['timezone_id'],
                        'end_advertiser' => $this->mybusinessId,
                        'media_agency'   => 'NONE',
                        'partner'        => 'NONE',
                        'access_type'    => 'OWNER',
                        'permitted_roles' => 'ADMIN'
                        //'user_role'        => '1001'
                        );

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$this->apiVersion.'/'.$this->mybusinessId.'/adaccount');
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);

它已成功创建广告帐户,但不会将我添加为具有管理员权限的用户。

谁能给我建议可能是什么原因?

创建广告帐户后,您需要再次拨打电话,为用户添加所需的权限。

$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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM