您可以訂閱global events來完成此操作。
如果您訂閱auth.login,auth.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);
}
});
}
});