Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 14th, 2013  |  syntax: None  |  size: 1.81 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. FacebookClient _FacebookClient = new FacebookClient ( Settings.AccessToken );
  2.  
  3. FacebookClient.PostCompleted += new EventHandler<FacebookApiEventArgs> ( _FacebookClient_PostCompleted );
  4.  
  5. FacebookClient.BatchAsync
  6. (
  7.     new FacebookBatchParameter [ ]
  8.     {
  9.         new FacebookBatchParameter( HttpMethod.Get , "/me/friends" , new Dictionary<string , object> { { "fields" , "id , name , picture" } } ) { Data = new { name = "one-friend", omit_response_on_success = false } } ,
  10.         new FacebookBatchParameter{ Parameters = new { ids = "{result=one-friend:$.data.0.id}" } },
  11.         new FacebookBatchParameter("{result=one-friend:$.data.0.id}/statuses",  new Dictionary<string , object> { { "limit" , "1" } , { "data" , "0" } , { "fields" , "message" } } )
  12.     }
  13. );
  14.        
  15. string query0 = "SELECT uid2 FROM friend WHERE uid1 = me()"; //here you get the friends list
  16. string query1 = "SELECT uid, message, status_id FROM status WHERE uid IN (SELECT uid2 FROM #query0)"; //here you get the last statuse of each friend (max 50, or max from the last 30 days)
  17. string query2 = "SELECT uid, name FROM user WHERE uid IN (SELECT uid FROM #query1)"; //here you get the user data (in this case the name only)
  18.  
  19. dynamic result = fb.Query(query0, query1, query2); //all results
  20. dynamic status = result[1][1]; //results of query1
  21. dynamic friend = result[2][1]; //results of query2
  22.  
  23. for (int i = 0; i < result[1][1].Count; i++)
  24. {
  25.     litFeedback.Text += "<a href="http://www.facebook.com/profile.php?id=" + status[i].uid + "" target="_blank">" + friend[i].name + "</a> : "
  26.         + status[i].message + "<br/>" + Environment.NewLine;
  27. }
  28.  
  29. //if not using .net 4.0:
  30. //var result = (IList<object>)fb.Query(query1, query2);
  31. //var result0 = ((IDictionary<string, object>)result[0])["fql_result_set"];
  32. //var result1 = ((IDictionary<string, object>)result[1])["fql_result_set"];