Facebook – posting message on Facebook wall via flash/ActionScript

actionscript-3facebook

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 button 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);
} 
Related Topic