Tag Archives: facebook development

How to get count of Likes of the your facebook page in C#

get number of like of Facebook page
With the help of Facebook Graph API, we can get various information about any Facebook page. The Graph API as such allows you to easily access all public information about an object. The Graph API presents a simple, consistent view of the Facebook social graph and every object in the social graph has a unique ID. You can access the properties of an object by requesting https://graph.facebook.com/ID or https://graph.facebook.com/username.
 
For example, the username of the authorcode Facebook page is ‘authorcode’, so you can fetch the object at https://graph.facebook.com/authorcode.
 
We can also use the Facebook Graph api in c#.
 
Suppose if you want to get the total numbers of likes of your Facebook page, you can use the following code sample:

   private void GetCountLikes()
    {
        int number_of_likes = 0;
        object value = "";
        string url = "https://graph.facebook.com/authorcode";
        try
        {
            string jsonString = new System.Net.WebClient().DownloadString("https://graph.facebook.com/authorcode");
            System.Web.Script.Serialization.JavaScriptSerializer obj1 = new System.Web.Script.Serialization.JavaScriptSerializer();
            Dictionary<string, object> objDic = (Dictionary<string, object>)obj1.Deserialize<object>(jsonString);
            bool success = false;
            success = objDic.TryGetValue("likes", out value);
            if (success)
            {
                number_of_likes = (int)value;
            }
        }
        catch
        {
 
        }
    }

 
API provides us the information in JSON object so we are using System.Web.Script.Serialization.JavaScriptSerializer.Deserialize() function to get the information in efficient way.

Your First Facebook Windows Application in C#

 
This is good to hear that we can create facebook windows application in c#, some time ago I check the facebook developers tab and found you can create facebook applications for different types of platform.
On here we are describing the process for developing facebook desktop application with the help of Facebook C# SDK, Continue reading Your First Facebook Windows Application in C#