facebook init
Facebook.init('App ID', initLogin);
function initLogin(response:Object, fail:Object):void {//facebook init
}
facebook login
Facebook.login(handleLogin,{perms:"user_birthday,read_stream,publish_stream,user_photos"});
function handleLogin(response:Object, fail:Object):void {//facebook login
if(response!=null){
Facebook.api('/me', onMyInfoLoaded);
}
}
load facebook info and post data
function onMyInfoLoaded(response:Object,fail:Object):void {//facebook info success
if(response!=null){
var params:Object = {
source: 'http://xxx.jpg',
picture: 'http://xxx.jpg',
message: 'text',
link: 'http://adidas-oba2011-2.youthwant.com.tw',
name: 'Adidas is all in',
caption: '內容',
description: '內容'
};
Facebook.postData('/me/feed', requestHandler, params);
}
}
function requestHandler(result:Object, fail:Object):void{
if (result != null){
if (result.error_msg != null){
//error
}else{
//success
}
}
if (fail != null){
//error
}
}
0 意見:
張貼留言