1

當用戶訪問我的網站並嘗試允許發佈操作權限時,他將點擊'add-to-timeline'插件按鈕。
然後出現一個彈出對話框,用戶將允許所需的權限。
我想知道的是,如果我們可以指定任何回調函數在用戶允許後調用。添加到時間線插件的回調?

我知道我們可以通過FB.Event.subscribe訂閱'edge.create'事件,但是我找不到'add-to-timeline'類似的解決方案。
至少,它沒有寫在我的文檔上。
有人能幫助我嗎?

回答

3

您可以訂閱global events來完成此操作。

如果您訂閱auth.loginauth.authResponseChange,或auth.statusChange用戶授權通過 'add-to-timeline' 您的應用程序後,他們將被調用。

因此,例如,你可以這樣做......

FB.Event.subscribe('auth.login', function(response) { 
    alert('The user has just authorized your application'); 
}); 

不過我猜你想要的是,我想同樣的事情是有動作添加到時間線上用戶點擊後'第一次添加到時間線',然後在後續訪問您的網站時,它會自動添加到時間線中。

要做到這一點,你會做到這一點...

/** put your FB.init right here **/ 

FB.Event.subscribe('auth.statusChange', function(response) { 
    if (response.status == 'connected') { 
    FB.api("/me/foobar:watch" + "?video=http://foobar.com/video/123","post", 
     function(response) { 
     if (!response || response.error) { 
      alert("Error"); 
     } else { 
      alert("Post was successful! Action ID: " + response.id); 
     } 
     }); 
    } 
});