【问题标题】:Unable to implement Facebook Java APi无法实现 Facebook Java API
【发布时间】:2018-05-06 04:29:55
【问题描述】:

我需要有关 Facebook 营销 API 的帮助。 我正在尝试使用 Facebook Java API 创建广告。 我已将电子邮件存储在我的数据库中,我希望我的程序获取这些电子邮件 ID 并将它们推送到自定义受众中。但我面临“AdCreative”的一些问题。它有两个名为 SetLinkUrl 和 SetObjectUrl 的参数。我不明白在这些参数中传递什么。我尝试将链接提供给我想要推广的页面,但它不起作用。

对于 AdCreative 部分,这就是我正在做的事情。

AdCreative creative = account.createAdCreative()
                  .setTitle("Java SDK Test Creative")
                  .setBody("Java SDK Test Creative")
                 //.setImageHash(imageFile.hashCode())
                 .setLinkUrl("xyz")
                 .setObjectUrl("xyz")
                  .execute();

这里,xyz 是我的 facebook 页面的链接。我收到了这个错误。

com.facebook.ads.sdk.APIException$FailedRequestException: {"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1885833,"is_transient":false,"error_user_title":"Ad Must Be Associated With a Facebook Page","error_user_msg":"Ads and ad creatives must be associated with a Facebook Page. Try connecting your ad or ad creative to a Page and resubmit your ad.","fbtrace_id":"HGmvidCVerR"}}
    at com.facebook.ads.sdk.APIRequest.readResponse(APIRequest.java:226)
    at com.facebook.ads.sdk.APIRequest.access$1(APIRequest.java:203)
    at com.facebook.ads.sdk.APIRequest$DefaultRequestExecutor.sendPost(APIRequest.java:409)
    at com.facebook.ads.sdk.APIRequest$DefaultRequestExecutor.execute(APIRequest.java:335)
    at com.facebook.ads.sdk.APIRequest.executeInternal(APIRequest.java:160)
    at com.facebook.ads.sdk.AdAccount$APIRequestCreateAdCreative.execute(AdAccount.java:1848)
    at com.facebook.ads.sdk.AdAccount$APIRequestCreateAdCreative.execute(AdAccount.java:1843)
    at demo.BasicExample.main(BasicExample.java:149)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://graph.facebook.com/v2.11/act_103127053798775/adcreatives
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.facebook.ads.sdk.APIRequest.readResponse(APIRequest.java:207)
    ... 7 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://graph.facebook.com/v2.11/act_103127053798775/adcreatives
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
    at com.facebook.ads.sdk.APIRequest.readResponse(APIRequest.java:205)
    ... 7 more

我刚刚在某处看到 facebook 不允许 facebook 域链接减少垃圾邮件。所以我不明白要在那里传递什么。请帮帮我。 或者,如果有人能解释整个“广告创意”部分,那就太好了。

另外,我不明白“图像哈希”部分。请解释

谢谢。

【问题讨论】:

    标签: facebook facebook-marketing-api facebook-java-api


    【解决方案1】:

    来自docs

    您将无法再创建或编辑未连接到有效页面的事件广告和链接广告。请求会返回错误:ErrorCode::ADPRO2__AD_MUST_HAVE_PAGE (1885833)

    还有:

    如果您在广告素材的 object_story_id 或 object_story_spec 字段中提供有效的 actor_id,您仍然可以创建事件广告和链接广告

    【讨论】:

    • 抱歉,我是新手。我没有得到 valid_actor_id、object_story_id 和 object_story_spec。你能解释一下吗?有效页面是什么意思?我正在尝试推广一个普通的 Facebook 页面。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    • 2013-06-22
    • 2012-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多