在创建广告帐户的Facebook营销api时如何使用管理员访问 [英] How to aduser with admin access while creating ad account facebook marketing api

查看:195
本文介绍了在创建广告帐户的Facebook营销api时如何使用管理员访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  $附件= 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); //抑制卷曲输出
$ result = curl_exec($ ch);
$ dcde = json_decode($ result);
curl_close($ ch);

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

任何人都可以给我建议什么是原因?

解决方案

一次该广告帐户已创建,您需要进行另一个呼叫,这将添加具有所需权限的用户。

  $ 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); //抑制卷曲输出
$ result = curl_exec($ ch);
$ dcde = json_decode($ result);
curl_close($ ch);


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

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

It successfully creates ad account but does not add me as a user in people with administrative access.

Can anyone give me suggestion what can be the reason?

解决方案

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

这篇关于在创建广告帐户的Facebook营销api时如何使用管理员访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆