【问题标题】:How to aduser with admin access while creating ad account facebook marketing api如何在创建广告帐户 facebook 营销 api 时使用管理员访问权限的 aduser
【发布时间】:2016-10-19 10:06:12
【问题描述】:

我正在尝试使用以下代码通过 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);

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

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

【问题讨论】:

    标签: php facebook-graph-api facebook-marketing-api


    【解决方案1】:

    创建广告帐户后,您需要进行另一个调用,以添加具有所需权限的用户。

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

    【讨论】:

    • 非常感谢。我从天数开始搜索这个..谢谢
    • @Jass 很高兴为您提供帮助 :)
    • @Jass,与其手动编写 curl 调用,不如使用Facebook Marketing Apis Sdk
    • @Haridarshan 这是正确的答案,这就是我使用它的方式,而且它有效。
    猜你喜欢
    • 1970-01-01
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    • 2022-12-23
    相关资源
    最近更新 更多