locked
check facebook user online status (C#)?

    Question

  • how can I check if a user on Facebook is online or offline in order to show a notification to the user?


    Jassim Rahma
    Friday, September 04, 2009 3:15 PM

All replies

  • Check out http://www.leeholmes.com/blog where he has written some powershell scripts to download albums from facebook. He uses System.Net.WebClient in those scripts. You can do a 1:1 translation from his powershell scripts into C# or VB code to do what you want.
    feroze
    --
    My blog
    Sunday, September 06, 2009 1:46 AM
  • Following link will help you

    http://wiki.developers.facebook.com/index.php/Main_Page


    Gaurav Khanna
    Sunday, September 06, 2009 6:31 PM
  • hi

    hi

    Saturday, August 14, 2010 6:33 AM
  • hi

    hi


    ky haal hy ap sub ka
    Saturday, August 14, 2010 6:34 AM
  • helllllllo

     

    Tuesday, December 28, 2010 8:48 AM
  • how can I check if a user on Facebook is online or offline in order to show a notification to the user?


    Jassim Rahma
    Ruan Gray
    Saturday, December 03, 2011 7:31 PM
  • Hi Jassim,

    Just try out this code below :

     

    public Collection<User> GetOnlineFriends() 
      { 
          Collection<string> onlineFriends = GetOnlineFriendIds(); 
          return GetUserInfo(StringHelper.ConvertToCommaSeparated(onlineFriends)); 
      } 
    
    

      public Collection<string> GetOnlineFriendIds() 
       { 
           Collection<string> friendList = new Collection<string>(); 
           string xml = GetOnlineFriendsXML(); 
           if (!String.IsNullOrEmpty(xml)) 
           { 
               XmlDocument xmlDocument = LoadXMLDocument(xml); 
               XmlNodeList nodeList = xmlDocument.GetElementsByTagName("fql_query_response"); 
               if (nodeList != null && nodeList.Count > 0) 
               { 
                   XmlNodeList results = xmlDocument.GetElementsByTagName("user"); 
                   foreach (XmlNode node in results) 
                   { 
                       friendList.Add(XmlHelper.GetNodeText(node, "uid")); 
                   } 
               } 
           } 
               return friendList; 
       } 
    
    

      public string GetOnlineFriendsXML() 
       { 
           Dictionary<string, string> parameterList = new Dictionary<string, string>(3); 
           parameterList.Add("method", "facebook.fql.query"); 
     
           if (!string.IsNullOrEmpty(_userId)) 
           {                 
               parameterList.Add("query",  
                   String.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", 
                                  "SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=", _userId, ") AND 'active' IN online_presence")); 
     
           } 
           else 
           { 
               throw new FacebookException("User Id is required"); 
           } 
           return ExecuteApiCallString(parameterList, true); 
       } 
    
    
    The above methods will suffice your question i suppose using c# and if you want to convert to vb then use the online conversion site

     

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    to show notifications to the user, just search www.Stackoverlow.com

     

     


    Thanks

    Rehan Bharucha - The Tech Robot

    MCTS, MCITP, MCPD, MCT

    Friday, December 23, 2011 2:20 PM