2017-02-15 5 views
0

ich von this page Informationen Kommentar (nach unten scrollen zu ** Kommentaren Plugin Code Generator * Abschnitt)Wie Facebook Kommentare kommen Kommentare Kommentare Informationen mit C#?

Ich verwende FacebookClient Klasse von Facebook Nuget package zu holen versuchen, die Daten zu holen. Mein Code ist folgende:

string oauthUrl = $"https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={appId}&client_secret={appSecret}"; 

string accessToken = client.DownloadString(oauthUrl).Split('=')[1]; 

// this is included as a sanity check that the client can fetch data (correct token, proper calls)  
var fbClient = new FacebookClient(accessToken); 
var fbData = fbClient.Get("/wikipedia/").ToString(); 
var info = JsonConvert.DeserializeObject<FacebookPageInfo>(fbData); 
fbData = fbClient.Get("/wikipedia/posts").ToString(); 
var posts = JsonConvert.DeserializeObject<FacebookPostData>(fbData); 

// this is the code the actually should fetch comments content 
// this is the data-href value retrieved from inspecting rendered page 
var pageUrl = HttpUtility.UrlDecode("https://developers.facebook.com/docs/plugins/comments#configurator"); 
var fbComments = fbClient.Get($"/{pageUrl}/comments"); 

aber ich erhalte nur ein JSON Ergebnis wie folgt ergeben:

{ 
    "og_object": { 
    "id": "246649445486535", 
    "description": "The Comments box lets people comment on content on your site using their Facebook profile and shows this activity to their friends in news feed. It also contains built-in moderation tools and special...", 
    "title": "Comments - Social Plugins - Documentation - Facebook for Developers", 
    "type": "article", 
    "updated_time": "2017-02-09T22:53:10+0000" 
    }, 
    "share": { 
    "comment_count": 0, 
    "share_count": 4226 
    }, 
    "id": "https:\/\/developers.facebook.com\/docs\/plugins\/comments#configurator\/comments" 
} 

Frage: Wie kann ich aktuelle Kommentare Inhalt holen?

+0

https://developers.facebook.com/docs/plugins/faqs#faq_1603507626630008 – CBroe

Antwort

0

Dank CBroe Ich habe richtig die Anfrage zu konstruieren und machen einen weiteren Schritt in Richtung fetching Kommentar Informationen verwaltet:

  1. #configurator Lesezeichen in der URL falsch war (es entfernt werden muss)

  2. richtigen Code zu holen Daten

    var pageUrl = HttpUtility.UrlDecode("https://developers.facebook.com/docs/plugins/comments"); 
    var fbComments = fbClient.Get($"https://graph.facebook.com/v2.6/?fields=og_object{{comments}}&id={pageUrl}"); 
    

Das Einfügen von pageUrl in Chrome ruft die Kommentare ab, schlägt aber in IE11 und in C# -Code fehl. Aber das ist ein anderes Thema für eine andere Frage.