これを実現するために、グローバル イベントをサブスクライブできます。
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);
}
});
}
});