Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I access a user's friend status using Facebook Graph API?
    text
    copied!<p>I am making an web app that shows the authenticated user's friends statuses. Is there anyway I can do this using <a href="https://developers.facebook.com/docs/reference/api/" rel="nofollow">Facebook's graph API</a>? The only thing I am finding is <code>FQL</code> which I can't use because I am not allowed to use php.</p> <p>Edit: Also I don't need alot of statuses. I only need their friends latest one.</p> <p>Edit: fbID is the facebook ID. Here is my code: </p> <pre><code>&lt;script&gt; var self; (function(d){ // Load the SDK Asynchronously var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); window.fbAsyncInit = function() { // Init the SDK upon load FB.init({ appId : '190843834372497', // App ID channelUrl : 'http://people.rit.edu/~cds7226/536/project3/channel.html', // Path to your Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); // listen for and handle auth.statusChange events FB.Event.subscribe('auth.statusChange', function(response) { if (response.authResponse) { // user has auth'd your app and is logged into Facebook FB.api('/me', function(me){ if (me.name) { document.getElementById('auth-displayname').innerHTML = me.name; //Add rest of code here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ self=me; } }) document.getElementById('auth-loggedout').style.display = 'none'; document.getElementById('auth-loggedin').style.display = 'block'; } else { // user has not auth'd your app, or is not logged into Facebook document.getElementById('auth-loggedout').style.display = 'block'; document.getElementById('auth-loggedin').style.display = 'none'; } }); document.getElementById('auth-loginlink').addEventListener('click', function(){ // respond to clicks on the login and logout links FB.login(function(response){},{scope: 'friends_status,read_stream'}); }); } &lt;/script&gt; </code></pre> <p>Then this function executes when you click the button. It gets the User's last checked in location, and personal information including their facebook ID.</p> <pre><code>function getFriendsCheckin(token) { $.getJSON('https://api.foursquare.com/v2/checkins/recent?oauth_token='+token+'&amp;v='+"20120514",function(results){ //console.log(results); $.each(results['response']['recent'], function(key,value){ //console.log(key+' : '+value); //Friends personal info var fullName = value['user']['firstName']+" "+value['user']['lastName']; var timeStamp = value['createdAt']; var photo = value['user']['photo']; var fbID = value['user']['contact']['facebook']; //Where they last checked in var locName = value['venue']['name']; var location = new google.maps.LatLng(value['venue']['location']['lat'],value['venue']['location']['lng']); //setMarker(location,fullName+'@'+locName); setCustomMarker(location,fullName+'@'+locName,fbID,photo); }); }) </code></pre> <p>}</p> <p>Lastly this is where the problem is. This function is suppose to show the user's friendd last status when the maker is clicked on google maps.</p> <pre><code>function setCustomMarker(location,title,fbID,icon) { //alert("here"); var marker = new google.maps.Marker({ position: location, draggable: false, map: map, title: title, //icon: icon //icon: new google.maps.MarkerImage({url: icon, size: new google.maps.Size({width:10,height:10})}) }); google.maps.event.addListener(marker,'click',function(){ console.log('SELECT status_id,message FROM status WHERE uid='+fbID); FB.api( { method: 'fql.query', query: 'SELECT status_id,message FROM status WHERE uid='+fbID }, function(response){ console.log(response); } );//*/ }); </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload