0

I have a FaceBook game that is done in SilverLight. It makes a call to JavaScript from the SilverLight HTML bridge. I do not want an UI that asks the user for a comment, I just want their score that was passed from the SilverLight app to post on their feed. The following code does nothing. It does not throw an exception, but does exactly nothing.

Any help you can send my way that will explain how to fix this so that it posts to a users feed without UI would be greatly, greatly appreciated.

function PostToFeed(strCaption) 
{

    function callback(response) 
    {
    }

    var obj = 
    {
        method: 'stream.publish',
                    // was using method: 'feed',
        link: 'https://apps.facebook.com/blackjackguru/',
        picture: 'https://metamorphosisapps.com/blackjackguru/BlackjackIcon.gif',
        name: 'Blackjack Guru Accomplishment',
        caption: strCaption,
        message: 'I love this game!',
        description:  'Play blackjack with the best blackjack game on FaceBook.'
    };

    FB.ui(obj, callback);
}
Kara
  • 6,115
  • 16
  • 50
  • 57
RickLeinecker
  • 449
  • 2
  • 6
  • 6

1 Answers1

1
var obj = 
    {           
        link: 'https://apps.facebook.com/blackjackguru/',
        picture: 'https://metamorphosisapps.com/blackjackguru/BlackjackIcon.gif',
        name: 'Blackjack Guru Accomplishment',
        caption: strCaption,
        message: 'I love this game!',
        description:  'Play blackjack with the best blackjack game on FaceBook.'
    };

FB.api('/me/feed', 'post', obj , function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response.id);
  }
});

have you tried this? this just posts to user feed without any questions :)

divide by zero
  • 2,340
  • 5
  • 23
  • 34
  • Yes, but to be sure I just tried it again. I think I have tried all of the different flavors of post to feed that are out there and for some reason it is not working. BTW: no alerts come up in response to the callback. – RickLeinecker Sep 04 '12 at 16:37
  • try debug, does it execute your function PostToFeed(strCaption)? strange behaviour, because there should be response in ANY case...but looks like that you don't even call the function. – divide by zero Sep 04 '12 at 16:39
  • Yes, I can add some alerts into the javascript code just to make sure it is getting there and the debug alerts appear. I have also used this at the end of the javascript method just to make sure that an exception wasn't being thrown. I also added a try/catch, but there don't seem to be any exceptions thrown. – RickLeinecker Sep 04 '12 at 16:42
  • Please provide us more code, so we take a look from the start point till the end. Thanks. – divide by zero Sep 04 '12 at 16:43
  • this code is working fine. you are having problem somewhere else. – Abhishek Sep 04 '12 at 16:43
  • I think there is some problem somewhere else. Any ideas where I can start looking? – RickLeinecker Sep 04 '12 at 16:46
  • Try to look from the point where you try to call this function. Find out whether the function is called. – divide by zero Sep 04 '12 at 16:48
  • I have narrowed it down. The FB.api call throws an exception that says "Undefined". I have done the proper FB.init (the FB.ui stuff works fine). – RickLeinecker Sep 04 '12 at 17:59
  • 1)try to remove some fields from `var obj` and add them one by one :) just in case of interest if you are still trying to figure out. 2)does your facebook object contain access token? you need to provide it in case you use api. Thanks. – divide by zero Sep 04 '12 at 18:45