简体   繁体   English

使用Facebook Ads API和Spring Social Facebook

[英]Using Facebook Ads API and Spring Social Facebook

I'm developing a SpringBoot application which needs to manage multiple Facebook Ad accounts. 我正在开发一个SpringBoot应用程序,该应用程序需要管理多个Facebook广告帐户。 I've successfully used the Facebook Java Ads SDK: 我已经成功使用了Facebook Java Ads SDK:

https://github.com/facebook/facebook-java-ads-sdk https://github.com/facebook/facebook-java-ads-sdk

to connect to a single Facebook ads account, via a Facebook app within the same account (account A) and create a campaign and query campaigns, ads sets, etc: 通过同一帐户(帐户A)中的Facebook应用连接到一个Facebook广告帐户,并创建广告系列并查询广告系列,广告集等:

public static final APIContext context = new APIContext(ACCESS_TOKEN, APP_SECRET);

    public static void main(String[] args)
    {
        try
        {
            AdAccount account = new AdAccount(ACCOUNT_ID, context);
            Campaign campaign = account.createCampaign().setName("Java SDK Test Campaign")
                    .setObjective(Campaign.EnumObjective.VALUE_LINK_CLICKS).setSpendCap(10000L)
                    .setStatus(Campaign.EnumStatus.VALUE_PAUSED).execute();
            System.out.println(campaign.fetch());
        } catch (APIException e)
        {
            e.printStackTrace();
        }
    }

Thew ACCESS_TOKEN, APP_SECRET and ACCOUNT_ID are all from the same Facebook account (account A), the one in which the Facebook app was created. ACCESS_TOKEN,APP_SECRET和ACCOUNT_ID都来自同一Facebook帐户(帐户A),即创建Facebook应用程序的帐户。 The Facebook app has the ads_management permissions reviewed and approved. Facebook应用具有已审核和批准的ads_management权限。

Now I need to be able to access Facebook Ad Accounts from other Facebook accounts. 现在,我需要能够从其他Facebook帐户访问Facebook广告帐户。 I've used the spring-social-facebook Accessing Facebook Data tutorial: 我使用过spring-social-facebook访问Facebook数据教程:

https://spring.io/guides/gs/accessing-facebook/ https://spring.io/guides/gs/accessing-facebook/

To register a different Facebook account (account B) with the Facebook App, using the scopes "ads_read, ads_management" and the account ID for the new Facebook account (account B) was added to the Facebook App from the original account (account A). 要使用范围“ ads_read,ads_management”在Facebook App中注册另一个Facebook帐户(帐户B),并且将新Facebook帐户(帐户B)的帐户ID从原始帐户(帐户A)添加到Facebook App中。

However, when I used the second account's account ID in the code above I get: 但是,当我在上面的代码中使用第二个帐户的帐户ID时,我得到:

 {"error":{"message":"Unsupported get request. Object with ID 'act_105428933326149' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"fbtrace_id":"Ee5exTqJdCp"}

Which suggests I have a permissions issue somewhere, but I'm stumped. 这表明我在某处存在权限问题,但很困惑。 I'm not even sure I'm following the correct approach. 我什至不确定我是否遵循正确的方法。

I've tried googling for an example of how to use the Facebook Ads API with spring-social-facebook, but other than a few commits to the repository which don't help a great deal, I can't find one. 我已经尝试使用Google搜索来搜索如何将spring-social-facebook与Facebook Ads API结合使用的示例,但是除了对存储库的一些提交没有多大帮助之外,我找不到一个。

Facebook Ads API has tiered access . Facebook Ads API具有分层访问权限 A newly registered app is in Development Tier and can only access the user's own ad accounts. 新注册的应用程序位于“开发层”中,只能访问用户自己的广告帐户。 You need to meet certain criteria to get promoted to Basic Tier and manage other people's ad account. 您需要满足某些条件才能晋升为基本层并管理其他人的广告帐户。

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

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