Question

I'm absolutely new to programming and just managed to learn the basics of ActionScript 3. Now, I would like to learn how to post on my Friends' Walls via the as3 SDK using the UI class (taken from a nice Tutorial):

This is how I post on my own Wall:

protected function newsFeed ():void
        {

            // define your caption text
            var theCaption:String = "CaptionText";

            // define the descrition text
            var theDescription:String = "Text for game Achievement";

            // We need to follow the FB docs to tell it what sort of input we are sending to FB
            // We are trying to set the 'feed'
            var methodInput:String = 'feed';

            var thePicture:String = "mylink/picture.png";
            var theLink:String = "mylink";
            var theName:String = "Name of FB Status Setter";

            // Create an object that we'll call 'data' and fill it with the actual data we're sending to Facebook
            var data:Object = {
                caption:theCaption, 
                description:theDescription, 
                picture:thePicture, 
                name:theName, 
                link:theLink
            };
          Facebook.ui(methodInput, data, onUICallback);
         }

protected function onUICallback(result:Object):void
    {
    // do something
    }

This works perfectly fine. I know that I have to integrate the parameter "to" somewhere. But I don't know where and how. Sorry I'm very very new to this. This is from Facebook Docs

Properties

from: The ID or username of the user posting the message. If this is unspecified, it defaults to the current user. If specified, it must be the ID of the user or of a page >that the user administers.

to: The ID or username of the profile that this story will be published to. If this >is unspecified, it defaults to the the value of from.

Hopefully someone can help me out.

Best Regards, Amir P.S.: Is there a way to post only one friend's wall and another way to post on several friends' walls?

Was it helpful?

Solution

I believe you want to use Facebook.api() rather than 'ui'. According to the documentation for the AS3 FB API, 'ui' just opens the share dialog. If you want to create a post on a friends wall, then you'll want to use 'api'.

I haven't tested this in Flash, but I think you can set the method as /PROFILE_ID/feed ... of course replacing "PROFILE_ID" with the FB uid of the friend. Then, include the arguments; message, picture, link, name, caption, description and source in your data object.

So your code would look something like:

var method:String = "/friend_id/feed";
var data:Object = {};

data.message = "Your message";
data.picture = "http://www.google.com/kittens.jpg";
data.link = "http://www.mysite.com/link";
data.caption = "Your caption";
data.description = "Your description";
data.source = "http://www.mysite.com/video.swf";//(optional) source is a video or Flash SWF

Facebook.api(method, yourCallback, data, "POST");

function yourCallback(result:Object, fail:Object):void {
    if (result) {
        trace(result)
    } else if (fail) {
        trace(fail);
    }
}

If you have multiple friends, you could probably just put the uid's in an array and loop through the method above. The AS3 API has a batch request method that I haven't tried, but you can check out the Documentation.

Facebook has some pretty helpful tools that are somewhat hidden.
Checkout their Debugger and their Graph API Explorer

Hope that's helpful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top