我正在创建一个需要与Facebook集成的游戏。游戏完成后,一旦用户完成游戏,就会添加将分数发送到用户的Facebook墙上的按钮。
我已经下载了适用于Flash的Facebook API,并且可以连接到用户并获取其ID。但我不知道使用什么命令通过swf在用户墙上发布乐谱或消息。
以下是基本代码......
import com.facebook.data.users.GetInfoData;
import com.facebook.utils.FacebookSessionUtil;
import com.facebook.data.users.FacebookUser;
import com.facebook.data.users.GetInfoFieldValues;
import com.facebook.data.friends.GetFriendsData;
import com.facebook.commands.users.GetInfo;
import com.facebook.commands.friends.*;
import com.facebook.net.FacebookCall;
import com.facebook.events.FacebookEvent;
import com.facebook.Facebook;
var fbook:Facebook; // Creating variable for facebook instance
var session:FacebookSessionUtil; //a utility for flash session is created
session = new FacebookSessionUtil("myAPPIT", "KEY", loaderInfo);// initializing the session
session.addEventListener(FacebookEvent.CONNECT, onFacebookConnect, false, 0, true);// checking if the face book is connected
fbook = session.facebook; // fbook holds the facebook instance as a property
fbook.login(true); // connected to the facebook
login_btn.addEventListener(MouseEvent.CLICK, connectToFB);
function connectToFB(e:Event):void
{
session.validateLogin();
}
function onFacebookConnect(e:FacebookEvent):void
{
trace("Is Facebook connected: " + fbook.is_connected);
var call:FacebookCall = fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);
}
function onGetInfo(e:FacebookEvent):void
{
var user = (e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
trace("Hello, " + user.first_name + " " + user.last_name);
}
答案 0 :(得分:1)