1

I have to get Facebook likes for a particular page,

I have gone through

How to get Facebook likes count for a Facebook page?, but following this, accesstoken will be expired by some sort of time and also tried to regenerate the accesstoken as below:

    public static string RefreshAccessToken(string currentAccessToken)
    {
        var client = new WebClient();       
        FacebookClient fbClient = new FacebookClient();
        Dictionary<string, object> fbParams = new Dictionary<string, object>();          
        fbParams["client_id"] = "xxxxxxxxxxxxxxx";
        fbParams["grant_type"] = "fb_exchange_token";
        fbParams["client_secret"] = "xxxxxxxxxxxxxxx";
        fbParams["fb_exchange_token"] = currentAccessToken;
        JsonObject publishedResponse = fbClient.Get("/oauth/access_token", fbParams) as JsonObject;
        string newaccesstoken = publishedResponse["access_token"].ToString();           
        return newaccesstoken;
    }

it was also failed, can you please tell me how to get likes count only without never expire accesstoken?

Community
  • 1
  • 1
  • Use your app access token (if the page is public, and not restricted in any way), or an extended page access token. – CBroe Nov 14 '16 at 10:14
  • How to get Appaccesstoken?App accesstoken location please –  Nov 14 '16 at 10:34
  • https://developers.facebook.com/docs/facebook-login/access-tokens, http://stackoverflow.com/a/12951233/1427878 – CBroe Nov 14 '16 at 10:35
  • I have used to get appaccesstoken by https://developers.facebook.com/tools/explorer/xxxxxxxxxxx?method=POST&path=me%3Ffields%3Dlikes&version=v2.8, but this time,https://graph.facebook.com/weloveeggs/?fields=likes&access_token=xxxxxxxxxxxx|PRdERhw4fwXwdivaN3WcUrfxMuY, didn;t show likes count –  Nov 14 '16 at 10:39
  • You are asking for the wrong field - `likes` is the other pages that have been liked by this page; what you want, is the `fan_count`. – CBroe Nov 14 '16 at 10:40
  • is the page likes count as fancount?and also will be expire this appaccesoken ? –  Nov 14 '16 at 10:41
  • Thanks, it works for me now –  Nov 16 '16 at 05:56

0 Answers0