Facebook-您不需要访问该个人资料的权限 [英] Facebook - You don't have required permission to access this profile

查看:266
本文介绍了Facebook-您不需要访问该个人资料的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一项服务,使用户可以根据我们的电子邮件数据库创建具有自定义受众群体的facebook广告.

I'm trying to build a service that let's users create facebook ads with a custom audience based on our database of emails.

在创建Facebook广告之前,我想创建广告预览.当我使用自己的帐户(facebook应用程序的管理员)登录时,此方法工作正常,但以测试用户身份登录时,此操作将失败.

Before creating the facebook ad I want to create a preview of the ad. This works just fine when I login in with my own account (admin of facebook app) but fails when logging in as test user.

这是用户将要执行的操作: 1.访问服务的网站. 2.使用Facebook帐户登录,范围为:public_profile,电子邮件,manage_pages,publish_pages,business_management,ads_management 3.选择要使用的facebook页面 4.创建AdCreative.由此可以进行广告预览.但是创建Adcreative失败,并给我以下错误:

This is what the user will do: 1. Visit the website of the service. 2. Login using Facebook account with scope: public_profile,email,manage_pages,publish_pages,business_management,ads_management 3. Select facebook page to use 4. Create AdCreative. From this an ad preview can be made. But it fails creating an Adcreative and gives me the following error:

"error":{"message":"Application does not have permission for this action","type":"OAuthException","code":10,"error_subcode":1341012,"is_transient":false,"error_user_title":"No permission to access this profile","error_user_msg":"You don't have required permission to access this profile","fbtrace_id":"EgTeMOXPCUp"}}

访问令牌以及广告帐户都属于facebook应用.我也尝试使用页面访问令牌,但是我没有访问广告帐户的权限. 这是代码:

The access token as well as ad account belongs to the facebook app. I tried to use the page access token as well but then I don't have permission to access the ad account. This is code:

function fbadcreative($url, $message, $carasoul, $fbtoken, $pageid){

$calength = count($carasoul);
$children = array();
for($i = 0; $i < $calength; $i++){
    $caitem = $carasoul[$i];
    $caitem['hash'] = fbaddimage($caitem['picture'], $caitem['id']);
    $child = (new AdCreativeLinkDataChildAttachment())->setData(array(
        AdCreativeLinkDataChildAttachmentFields::LINK => $caitem['link'],
        AdCreativeLinkDataChildAttachmentFields::NAME => $caitem['name'],
        AdCreativeLinkDataChildAttachmentFields::DESCRIPTION => $caitem['description'],
        AdCreativeLinkDataChildAttachmentFields::IMAGE_HASH => $caitem['hash'],
    ));
    $children[] = $child;
}
$link_data = new AdCreativeLinkData();
$link_data->setData(array(
  AdCreativeLinkDataFields::LINK => $url,
  AdCreativeLinkDataFields::CAPTION => $url,
  AdCreativeLinkDataFields::MESSAGE => $message,
  AdCreativeLinkDataFields::MULTI_SHARE_END_CARD => false,
  AdCreativeLinkDataFields::MULTI_SHARE_OPTIMIZED => false,
  AdCreativeLinkDataFields::CHILD_ATTACHMENTS => $children,
));
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
  AdCreativeObjectStorySpecFields::PAGE_ID => $pageid,
  AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
));

$creative = new AdCreative(null, 'act_<accountid>');
$creative->setData(array(
  AdCreativeFields::NAME => $url,
  AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));
try {
    $creative->create();
     return $creative->id;
    //return $creative->read(array(AdCreativeFields::ID,));
} catch (FacebookAds\Http\Exception\AuthorizationException $e) {
    echo 'Message: ' . var_dump($e);
    $previousException = $e->getPrevious();
    // Do some further processing on $previousException
    exit;
}

推荐答案

我知道这是一篇较旧的文章,但是其他人可能会读到如何解决这个问题.

I know this is an older post, but it might be interesting for others to read how to solve this.

您需要向通过api请求广告的用户提供广告,并分析将为其创建广告素材的PAGE上的权限.

You need to give the user that requests via api the Advertise and analyze permissions on the PAGE the ad creative will be created for.

此处使用图形浏览器的示例请求: page_id/assigned_users?user=system_user_id&tasks=['ADVERTISE', 'ANALYZE']

Example request here using the graph explorer: page_id/assigned_users?user=system_user_id&tasks=['ADVERTISE', 'ANALYZE']

这篇关于Facebook-您不需要访问该个人资料的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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