簡體   English   中英

FB.ui()忽略“ to”屬性

[英]FB.ui() ignoring the “to” property

有沒有人遇到過FB.ui的“ to”屬性被忽略的情況(即使已設置),並且帖子出現在當前登錄用戶的牆上嗎?

當使用FB示例代碼(以及硬編碼的參數值)處理完全精簡的測試頁時,它會按預期發布到我的牆上。 但是,當我在此FB代碼中添加“ to”屬性時,它仍然僅發布到我的牆上。

任何想法都將不勝感激,因為我以我認為是徹底的方式來拖曳了這些存檔和FB開發站點。

SDK會正確加載,並且會彈出iframe(盡管它會滾動到頁面頂部)。

這是我的測試頁中使用的簡化代碼:

$("#well").click(function(e) {
  FB.ui(
  {
   method: 'feed',
   to: '***', /* <=== this person is a confirmed friend with appropriate privacy settings */
   name: 'The Facebook SDK for Javascript',
   caption: 'Bringing Facebook to the desktop and mobile web',
   description: (
      'A small JavaScript library that allows you to harness ' +
      'the power of Facebook, bringing the user\'s identity, ' +
      'social graph and distribution power to your site.'
   ),
   link: 'https://developers.facebook.com/docs/reference/javascript/',
   picture: 'http://www.fbrell.com/public/f8.jpg'
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);

提前致謝。

##更新##

感謝Sahil Mittal的貢獻,我制定了一個相當合理的解決方案:

`

var jqxhr = $.get( "http://graph.facebook.com/"+$("#fbto").val()+"?fields=id", function( data ) {
 // could do something useful here... 
})

.done(function(  data ) {
  // do something else useful useful, in this case finish posting stuff to the wall 
})

.fail(function(  data ) {
 // thrown if the user doesn't exist
})

.always(function(  data ) {
  // etc... 
})

`

現在,這是一個jQuery 1.8。*解決方案,我還應該補充一點,在交通繁忙的情況下,我不確定FB會如何認真對待其URL,以將提交的用戶名轉換為ID。 但是,如果我們到達那座橋,我會很樂意過橋!

再次感謝Sahil。

您不能在to參數中使用username 您必須改用id

如果您沒有該ID,則可以從用戶名本身獲取。 撥打電話/{username}?fields=id ,您將獲得ID作為響應。

例如: http : //graph.facebook.com/sahilmittal?fields=id

響應為:

{
  id: "595273610"
}

只需獲取此id ,然后在to參數中使用它to

暫無
暫無

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

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