我需要创建一个Java应用程序,每天在数据库中存储来自商业帐户的广告名称。身份验证Facebook的广告api
这些都是采取的步骤:
-I加入Facebook的业务访问他们的广告帐户
-I登记在developers.facebook.com的应用程序。 -Got从https://developers.facebook.com/tools/debug/accesstoken/ 访问令牌 - 得到了来自该应用程序面板
应用程序的秘密这是代码片段:
public static final String ACCESS_TOKEN = [the token from above];
public static final Long ACCOUNT_ID = [the business account it];
public static final String APP_SECRET = [the scret from
public static void main(String...args) throws Exception {
APIContext context = new APIContext(ACCESS_TOKEN, APP_SECRET);
AdAccount account = new AdAccount(ACCOUNT_ID, context);
System.out.println(account.getAds().execute().getRawResponseAsJsonObject());
}
我得到以下错误:
com.facebook.ads.sdk.APIException$FailedRequestException: {"error":{"message":"(#273) This Ads API call requires the user to be admin of the ad account. User is not admin on ad account XXXXXXXX.","type":"OAuthException","code":273,"fbtrace_id":"GD30f+ON/k4"}}
我有以下问题:
1 - 为什么我需要管理员权限才能列出我可以看到的相同广告他的广告管理页面?
2 - 如果我的用户失去了访问企业帐户的权限,但是我希望Java仍能正常工作,该怎么办?其他用户仍可以运行Java代码吗?
3-上面的描述和代码有什么不对吗?
4 - 如何生成永久令牌而不是临时令牌?