I'm trying to extract Facebook comments from a Facebook Live video using Facebook Graph API (Explorer). I managed to login in and extract data from my user like my name and profile picture. I successfully extracted single line data like the name of the post and time it was posted, but I'm struggling with getting list data like comments, likes or reactions. When attempting to get list data the following text is displayed: "System.Collections.Generic.Dictionary`2[System.String,System.Object]" The error displays: "KeyNotFoundException: The given key was not present in the dictionary." Here is my code: using System.Collections; using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; //to use dictionaries and lists using Facebook.Unity; //to use unity functions public class FBScript : MonoBehaviour { public GameObject DialogLoggedIn; public GameObject DialogLoggedOut; public GameObject DialogUsername; public GameObject DialogProfilePic; public GameObject DialogPostID; public GameObject DialogPostUsername; public GameObject DialogPostComment; // Update is called once per frame void Awake () { FB.Init (SetInit/*, OnHideUnity*/); } void SetInit() { if (FB.IsLoggedIn) { Debug.Log ("FB is logged in"); } else { Debug.Log ("FB is not logged in"); } DealWithFBMenues (FB.IsLoggedIn); } //---LOGGING IN--- //-------------------- public void FBlogin() { List<string> permissions = new List<string> (); permissions.Add ("public_profile"); permissions.Add ("user_about_me"); permissions.Add ("user_friends"); permissions.Add ("manage_pages"); permissions.Add ("user_photos"); permissions.Add ("user_posts"); FB.LogInWithReadPermissions (permissions, AuthCallBack); } void AuthCallBack(IResult result) { if (result.Error != null) { Debug.Log (result.Error); } else { if (FB.IsLoggedIn) { Debug.Log ("FB is logged in"); } else { Debug.Log ("FB is not logged in"); } DealWithFBMenues (FB.IsLoggedIn); } } void DealWithFBMenues(bool isLoggedIn) { if (isLoggedIn) { DialogLoggedIn.SetActive (true); DialogLoggedOut.SetActive (false); FB.API("/me/?fields=first_name", HttpMethod.GET,DisplayUsername); FB.API("/me/picture?type=square&height=150&width=150", HttpMethod.GET,DisplayProfilePic); } else { DialogLoggedIn.SetActive (false); DialogLoggedOut.SetActive (true); } } //---REQUESTING DATA--- //---------------------------- public void FBRequestData() { FB.API("/632374026862851_938491859584398/?fields=comments{id}", HttpMethod.GET,DisplayPostID); FB.API("/632374026862851_938491859584398/?fields=comments{from}", HttpMethod.GET,DisplayPostUsername); FB.API("/632374026862851_938491859584398/?fields=comments{message}", HttpMethod.GET,DisplayPostComment); } //---LOGIN DATA--- //-------------------- void DisplayUsername (IResult result) { Text UserName = DialogUsername.GetComponent<Text> (); if(result.Error == null) { UserName.text = result.ResultDictionary ["first_name"] + " is Logged In"; } else { Debug.Log (result.Error); } } void DisplayProfilePic (IGraphResult result) { if (result.Texture != null) { Image ProfilePic = DialogProfilePic.GetComponent<Image> (); ProfilePic.sprite = Sprite.Create (result.Texture, new Rect (0, 0, 150, 150), new Vector2 ()); } else { Debug.Log (result.Error); } } //---POST DATA--- //------------------- void DisplayPostID (IGraphResult result) { Text PostID = DialogPostID.GetComponent<Text> (); if(result.Error == null) { PostID.text = result.ResultDictionary ["comments"] + " ost ID"; } else { Debug.Log (result.Error); } } void DisplayPostUsername (IGraphResult result) { Text PostUsername = DialogPostUsername.GetComponent<Text> (); if(result.Error == null) { PostUsername.text = result.ResultDictionary ["from"] + " ost Username"; } else { Debug.Log (result.Error); } } void DisplayPostComment (IGraphResult result) { Text PostComment = DialogPostComment.GetComponent<Text> (); if(result.Error == null) { PostComment.text = result.ResultDictionary ["message"] + " ost Comment"; } else { Debug.Log (result.Error); } } } Here's a link to what's happening:
I get the feeling it's something to do with this, but I still can't get to grips with it (I'm a very beginner coder): https://developers.facebook.com/docs/unity/reference/current/Json