1

我需要有关 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 域链接减少垃圾邮件。所以我不明白要在那里传递什么。请帮帮我。或者,如果有人可以解释整个“广告创意”部分,那就太好了。

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

谢谢。

4

1 回答 1

1

文档

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

还:

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

于 2017-11-22T13:14:50.550 回答