簡體   English   中英

Facebook Javascript SDK open-graph:為自定義故事添加自定義對象時出錯

[英]Facebook Javascript SDK open-graph: error adding custom objects for custom stories

我創建了一個名為“Opinion”的自定義對象來圍繞它構建自定義故事。

我正在嘗試使用javascript sdk從我的網站添加一些應用程序擁有的對象。

facebook給我的示例代碼是:

FB.api(
  'me/objects/[namespace]:opinion',
  'post',
  {
    app_id: xxxxxxxx,
    type: "[namespace]:opinion",
    url: "http://samples.ogp.me/331257847005141",
    title: "Sample Opinion",
    image: "https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png",
    description: ""
  },
  function(response) {
    // handle the response
  }
);

響應是一個錯誤(OAuth異常):

2500: Cannot specify type in both the path and query parameter.

如果我刪除type參數,我得到另一個錯誤:

(#100) The parameter object is required

如果我從路徑中刪除[namespace]:opinion ,則相同。

我不明白為什么,谷歌搜索后沒有任何參考。

為什么這個? 我可以參考解決的任何資源?

該對象是對象的JSON編碼版本,為您生成的示例代碼不正確。 同時從參數列表中刪除類型。

所以,像,

FB.api(
  'me/objects/[namespace]:opinion',
  'post',
  {
    object: {"app_id":xxx,"url":"http:\/\/samples.ogp.me\/331257847005141","title":"\"Sample Opinion\"","image":"https:\/\/s-static.ak.fbcdn.net\/images\/devsite\/attachment_blank.png","description":"\"\""}
  },
  function(response) {
    // handle the response
  }
);

http://philippeharewood.com/facebook/objectify.html上可以看到它的外觀示例,它基於https://developers.facebook.com/docs/opengraph/using-object上給出的卷曲示例。 -API /

對於在iOS上遇到類似問題的人來說,示例代碼似乎再次出錯,但以下似乎有效:

NSMutableDictionary<FBOpenGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"<appnamespace>:<objecttype>"
    title:@"..."
    image:[result objectForKey:@"uri"]
      url:nil
  description:@"..."];

[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
    // handle the result
    if ( error ) {
        DLog(@"error %@ creating object", error);
    } else {
        ...
    }
}];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM