views:

13

answers:

1

I am able to successfully post Flash content using FB.ui({method: 'stream_publish',....}).

However, since my app must also be able to post to Fan Pages, I cannot use FB.ui, and must use the Graph API via FB.api instead. No biggie, I'd rather have a custom form for posting anyway.

But it seems posting to a feed using FB.api('/FEED_ID/feed', ...) takes different parameters than the FB.ui method.

Documentation for the FB.api call and the Graph API is not particularly helpful. The Graph API docs mention a source parameter, which is supposed to be the url to the flash object. However, when I set source to be the flash object url, I get the following:


(#100) flash objects must have the 'swfsrc' and 'imgsrc' attributes.


OK, fine, but where do they go? The attachment parameter, which worked fine for FB.Connect and FB.ui, seems to be completely ignored.

Here's my code:

        body = {
                    name: "Name",
                    link: "http://mysite.com/link_to_my_content",
                    caption: "This is the caption",
                    message: "Test Message",
                    source: 'http://mysite.com/static/flash.swf',
                    image: 'http://mysite.com/static/images/facebook_thumb.png',
                    actions: action_links,
                    description: "The fascinating, compelling description"
                }

                FB.api('/me/feed', 'post', body, function(response){
                    if (!response || response.error){
                        console.log("FB.api error occurred");
                        if (response.error){
                            console.log("Error message: " + response.error.message);
                        }
                    }
                    else {
                        console.log("Post successful: " + response);
                    }
                });

When posting to a Fan Page I also include the access_token parameter (and changing the url obviously) which seems to work fine. I just can't figure out how to get the flash content to publish. Where do the swfsrc and imgsrc attributes go? It's probably something that will seem obvious but I've tried everything I can think of. Google isn't helpful as it seems most people are just using stream_publish, and a bunch of old FB.Connect stuff.

A: 

This seems to work: Use picture instead of imgsrc, and source replaces swfsrc.

From http://bugs.developers.facebook.net/show_bug.cgi?id=10672#c17

Bascically, use the code above but replace image with picture.

Chris Lawlor