Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iframe dialogs must be called with a session key

I'm trying to call FB.ui to make a wall post in an iframe. However, when I set display to iframe, I get a 102 error "Iframe dialogs must be called with a session key". I have an access token, I'm logged in, everything else seems to be working (I can even post directly to the stream with PHP without bringing up the prompt). Any ideas?

PHP:

require_once('facebook.php');
define('APP_ID',"276733022359677");
define('APP_SECRET',"xxxx");
$my_url = URI_B."/spider/";

$config = array();
$config['appId'] = APP_ID;
$config['secret'] = APP_SECRET;
$facebook = new Facebook($config);
$fbid = $facebook->getUser();
if($fbid == 0){
    $scope = "";
    header("Location: ".$facebook->getLoginUrl($scope));
}

Javascript:

FB.init({appId: "276733022359677", status: true, cookie: true});
function publish() {
    var obj = {
        display: 'iframe',
        method: 'feed',
        link: 'http://discussiontopic.comyr.com/spider/',
        name: 'Test',
        caption: 'Test Caption',
        description: 'This is a test.'
    };

    FB.ui(obj);
}

I also get an unspecified error at the login page (if redirected there to log in).

like image 478
djh101 Avatar asked Nov 13 '11 23:11

djh101


1 Answers

If you have the user's access token, specify it as a parameter to the FB.ui call:

var obj = {
    display: 'iframe',
    access_token: '<%= $access_token %>',
    method: 'feed',
    link: 'http://discussiontopic.comyr.com/spider/',
    name: 'Test',
    caption: 'Test Caption',
    description: 'This is a test.'
};
like image 84
Jesse Proulx Avatar answered Oct 31 '22 01:10

Jesse Proulx