Facebook 發佈到塗鴉牆
其實 FB.ui 跟 FB.api 都可以發佈到塗鴉牆
兩者的差異是一個會跳出 dialog 詢問,一個是直接就貼塗鴉牆了
FB.init({ appId: '你的 app ID', status: true, cookie: true, xfbml: true, channelURL: 'http://www.xxxxxxxx.com.tw/channel.html', oauth: true }); FB.getLoginStatus(function (response) { if (response.status === 'connected') { var uid = response.authResponse.userID; //var accessToken = response.authResponse.accessToken; //accessToken 的功用可以看這裡 http://developers.facebook.com/docs/reference/api/">http://developers.facebook.com/docs/reference/api/ login_success(uid); } else { FB.login(function (response) { if (response.authResponse) { var uid = response.authResponse.userID; var accessToken = response.authResponse.accessToken; login_success(uid); } else { alert('登入失敗!'); } }, { scope: 'email,publish_stream' }); } }) function login_success(uid){ /*var body = '測試一下測試一下測試一下測試一下'; FB.api('/me/feed', 'post', { message: body }, function(response) { if (!response || response.error) { alert('Error occured'); } else { alert('Post ID: ' + response.id); } }); */ FB.ui( { method: 'feed', name: 'Facebook Dialogs', link: 'http://www.suncolor.com.tw', picture: 'http://fbrell.com/f8.jpg', caption: '測試一下', description: '測試兩下測試兩下測試兩下' }, function(response) { if (response && response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } ); }
FB.ui 會長這樣
FB.api 會直接這樣