开发者

posting message on Facebook wall via flash/ActionScript

I am creating a game that needs to be integrated with Facebook. The game is done and once the user complets that game it adds the butt开发者_Go百科on that send score to the Facebook wall of the user.

I have downloaded the Facebook api for flash and is able to connect to the user and get its id. But I don't know what command to use to post the score or message on users wall via swf.

Below is the basic codes...


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);
} 


you need this function

http://developers.facebook.com/docs/reference/rest/stream.publish

quick example could be find here:

http://novacoders.blogspot.com/2010/02/publish-post-to-facebook-wall-news.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜