views:

274

answers:

1

I am trying to get my status from facebook using the javascript api. I have the following code:

    <div id="fb-root"></div>
<div id="data"></div>
<script src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
<script type="text/javascript">

(function(){
    FB.init({
        appId  : 'SOME ID',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
    });
});
getData();


function getData(){
    var query = FB.Data.query('SELECT message FROM status WHERE uid=12345 LIMIT 10');


    query.wait(function(rows) {
        for(i=0;i<rows.length;i++){
            document.getElementById('data').innerHTML += 'Your status is ' + rows[i].message + '<br />';
        }
    });
}

</script>

When i try to get my name it works fine but the status is not working. Can someone please tell me what I am doing wrong because the documentation for this is horrible. And yes I replaced the uid with a fake one and yes i put in my app id because like i said when i try to get my name it works fine. Any help is appreciated.

A: 

you need the "read_stream" extended permission for the user. See here: http://developers.facebook.com/docs/authentication/permissions

read_stream - Provides access to all the posts in the user's News Feed and enables your application to perform searches against the user's News Feed

to request permissions, see here: http://developers.facebook.com/docs/authentication/ particularly the part about requesting additional permissions:

In the examples above, the OAuth process will return the user ID of the active Facebook user, with which you can fetch all the public parts of the user's profile via the Graph API. As mentioned above, if you need to fetch private data in the profile or if you want to request permission to publish to Facebook on a user's behalf, you will need to request extended permissions.

To request permissions via OAuth, use the scope argument in your authorization request, and include a comma separated list of all the permissions you want to request. For example, this authorization request asks for access to the users' photos and videos and requests permission to publish to the user's stream on their behalf:

https://graph.facebook.com/oauth/authorize?client_id=...&amp;redirect_uri=http://www.example.com/callback&amp;scope=user_photos,user_videos,stream_publish

To request additional extended permissions, you can redirect to the same authorization URL with all the permissions you want to request. We will automatically exclude those permissions your application already has for the current user and show a dialog requesting only those permissions that have not already been granted.

Mike Sherov
what about if I just want to display my news feeds on my site? kinda retarded you can get all the info you want about a user but cant pull there posts which are public lol.
ngreenwood6
the posts are not public. By definition, only your name and profile picture are public, and can be fetched without an access token. Anything else requires an access token, and specific permission to pull that information. Essentially, you need to authorize your website to know that it has permission to pull your data. There is no other way for Facebook to know that you're you.
Mike Sherov