0

I'm just wondering if it is possible to use the Facebook Javascript SDK and OAuth 2.0 in an Javascript bookmarklet, because I just can't get it to work. What I'm actually trying to do is to update my Facebook status through my bookmarklet, but it seems like FB.init does nothing. Also I don't get any failure responses.

Is it possible to do something like this or am I violating any sandboxes or so?

I'm using an jquery bookmarklet boilerplate which works great. When initializing the bookmarklet I append the sdk

    var d = document,
        js = d.createElement('script'),
        root_node = d.createElement('div');

    js.id = 'facebook-jssdk';
    js.async = true;
    js.src = "http://connect.facebook.net/en_US/all.js";
    root_node.id = 'fb-root';
    d.getElementsByTagName('body')[0].appendChild(root_node);
    d.getElementsByTagName('head')[0].appendChild(js);

and then call fb.init

    window.fbAsyncInit = function(){

        console.log('JS-SDK loaded');

        FB.init({ 
            appId: 'XXX', 
            status: true, 
            cookie: true,
            xfbml: true,
            oauth: true
        });

        FB.getLoginStatus(function(response){
            console.log(response);
        });

    };

Actually it looks like "console.log(response)" never gets called

Thanks, martin

martin
  • 1
  • 1
  • *can't get it work*, what did you do so far ? – Dhiraj May 10 '12 at 15:01
  • i updated my original post. dunno why, but it works now .. after a whole day of try & error. Now I have the problem that the fb.init method only works when i'm on the Canvas URL, which is defined in my facebook app settings. when i trigger the bookmarklet on another page nothing happens. Is there a way to get my bookmarklet work on any website? – martin May 11 '12 at 10:11

1 Answers1

0

You should probably have your bookmarklet open a new page on your Canvas URL and then have it post from that page.

tomdemuyt
  • 4,572
  • 2
  • 31
  • 60