Quantcast
Viewing all articles
Browse latest Browse all 2

Publish into facebook wall from flex

Recently I was working on a facebook application using flex and when i had to post/share a video to the facebook wall. I was using the conventional share method, had to navigate to another url and then share. Found an alternative way and better approach to post it directly from flex to anyone’s wall. We can do that by using the PublishPost method of the facebook actionscript api. But to do so the user must grant the permission to publish that into his wall. Now, in order to grant the permission there is grantExtendedPermission(S) in the facebook class.

Below is the complete code which posts a flash movie into the facebook wall from the flex application.

Step 1
First check whether the user has permission to post the movie into the wall. If permission is already granted then post directly to the wall else go for the permission post.

var call:HasAppPermission = new HasAppPermission(ExtendedPermissionValues.PUBLISH_STREAM, uid)
call.addEventListener(FacebookEvent.COMPLETE, onPermissionCheckComplete);
facebook.post(call);

Step 2

private function onPermissionCheckComplete(vEvent:FacebookEvent):void
{
if(vEvent.success && (vEvent.data as BooleanResultData).value)
{
publishOnWall();
}
else
{
facebook.grantExtendedPermission(ExtendedPermissionValues.PUBLISH_STREAM);
}
}

Step 3
Publish a flash movie into the wall

private function publishOnWall():void
{
var message:String = "publish a flash into the wall";
var attachment:Object= {media: [{
type: "flash",
imgsrc: "image url",
swfsrc: "flash url",
width: '110', height: '110', expanded_width: '280', expanded_height: '280'
}]};
actionLinkData:ActionLinkData = new ActionLinkData();
actionLinkData.href = "action link url";
actionLinkData.text = "caption";

var post:PublishPost = new PublishPost(message, attachment, [actionLinkData],target_id, uid');
var call:FacebookCall = facebook.post(post);

A little tip for the Facebook application developers using Actionscript. Good luck Image may be NSFW.
Clik here to view.
:)

The post Publish into facebook wall from flex appeared first on .


Viewing all articles
Browse latest Browse all 2

Trending Articles