This article shows two ways how to make publish to stream Wall (News feeds) from flash facebook application or game:
- Publish post to stream with no user actions (using Stream.publish)
- Publish to stream from rendered Feed form (using Facebook.streamPublish)
1. Publish to stream using Stream.publish method
You can find detailed description of this method here http://wiki.developers.facebook.com/index.php/Stream.publish
That is very detailed description and I only want to show how to use it from actionscript 3.
Most probably you use actionscript facebook API client libraries from here.When I have found description of Sream.publish method on page above and understood that I need to use it (without feed form rendering) I couldn't find any appropriate actionscript method in documentation. Only digging of client library source code helped me to find PublishPost class that allows calling Stream.publish method.
Here is example how to use this method from actionscript 3:
private function publishToStream():void{
var message:String = "Stream.publish example";
var attachment:Object = {media: [{
type: "image",
src: "http://novacoders.com/design/img/logo.gif",
href: "http://novacoders.com/"
}]};
var actionLinkData:ActionLinkData = new ActionLinkData();
actionLinkData.href = "http://novacoders.com/services/flashdevelopment/";
actionLinkData.text = "Flash games development";
var post:PublishPost = new PublishPost(message, attachment, [actionLinkData], fbook.uid);
post.addEventListener(FacebookEvent.COMPLETE, onPublish);
var call:FacebookCall = fbook.post(post);
}
private function onPublish(e:FacebookEvent):void{
if(e.error!=null){
// fbook.grantExtendedPermission("publish_stream");
trace("Publish to stream: " + e.error.errorMsg);
}else{
trace("Publish to stream: onPublish " + e.data);
}
}
2. Publish to stream from feed form using Facebook.streamPublish method
to be continued
would you please show the full fla or as file? i lose the part of
ReplyDeletevar call:FacebookCall = fbook.post(post); <<
thanks a lot
The user hasn't authorized the application to perform this action is what im getting from the else statement inside onPublish. What am I doing wrong. Thanx. Johan.
ReplyDeleteGreat post, thanks! How did you figure out the structure of the "attachment" parameter?
ReplyDeleteI get this error
ReplyDeletePublish to stream: The user hasn't authorized the application to perform this action
what can i do?? please can you help me
thanks
Can't wait for the second part:
ReplyDeletePublish to stream from feed form using Facebook.streamPublish method
Hi there!
ReplyDeleteMaybe you can help me with the permissions thing.
I get an error every time I run this code: "Publish to stream: The user hasn't authorized the application to perform this action".
I make fbook.grantExtendedPermission("publish_stream"); Facebook told that "You have already granted permissions to this application."
However, this error still appears. Thanks.
Thanks a lot dude!
ReplyDeleteyou ever gonna do the feed form option?
ReplyDeleteSeriously? #2 is exactly what I need....!
ReplyDeleteThanks for posting this, it's hard to find information on how to do this (except of course for using php etc).
ReplyDeletetime waste
ReplyDelete