Facebook Retrive Data using Graph API using c#

前端 未结 5 1463
北海茫月
北海茫月 2021-01-06 11:05

i have created desktop Facebook application using c# .net. i want to retrieve users message,post and chat history. which is convenient way to retrieve users all information.

相关标签:
5条回答
  • 2021-01-06 11:20

    Go to developer.facebook.com -> Tools & Support -> Select Graph API Explorer

    Here U get FQL Query, Access Token

    Then write code in C#.....

    var client = new FacebookClient();
    client.AccessToken = Your Access Token;
    
    //show user's profile picture
    dynamic me = client.Get("me?fields=picture");
    pictureBoxProfile.Load(me.picture.data.url);
    
    //show user's birthday
    me = client.Get("me/?fields=birthday");
    labelBirthday.Text = Convert.ToString(me.birthday);
    
    0 讨论(0)
  • 2021-01-06 11:24

    A bit late to the party but anyway:

    Add a reference to System.Net.Http and Newtonsoft.Json

    string userToken = "theusertokentogiveyoumagicalpowers";
    
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("https://graph.facebook.com");
    
        HttpResponseMessage response = client.GetAsync($"me?fields=name,email&access_token={userToken}").Result;
    
        response.EnsureSuccessStatusCode();
        string result = response.Content.ReadAsStringAsync().Result;
    
        var jsonRes = JsonConvert.DeserializeObject<dynamic>(result);
    
        var email = jsonRes["email"].ToString();
    }
    
    0 讨论(0)
  • 2021-01-06 11:29

    From what i see the app now only uses webhooks to post data to a data endpoint (in your app) at which point you can parse and use this. (FQL is deprecated). This is used for things like messaging.

    A get request can be send to the API to get info - like the amt. of likes on your page.

    The docs of FB explain the string you have to send pretty nicely. Sending requests can be done with the webclient, or your own webrequests. https://msdn.microsoft.com/en-us/library/bay1b5dh(v=vs.110).aspx

    Then once you have a string of the JSON formatted page you can parse this using JSON.NET library. It's available as a NUGEt package.

    0 讨论(0)
  • 2021-01-06 11:31

    you can check the Graph explorer tool on Developer.facebook.com , go to Tools and select graph explorer, its a nice tool which gives you exact idea about what you can fetch by sending "GET" and "POST" method on FB Graph APis

    0 讨论(0)
  • 2021-01-06 11:40

    http://www.codeproject.com/Articles/380635/Csharp-Application-Integration-with-Facebook-Twitt

    I hope this will help you.!!!

    0 讨论(0)
提交回复
热议问题