- Home /
Get Facebook User name with Facebook sdk Unity android
Hi I m developing an Android Game, i can login to facebook and want to return the facebook id and user name and display them via guitext. Thanks for your help
@Irongirl Hello , I too facing the same problem, i'm using prime31 social combo plugin.. if u came to know the answer . kindly help me too .. thanks ..
Answer by Swaminathan · Feb 20, 2014 at 06:27 AM
using Facebook.minijson;
FB.API("me?fields=name", Facebook.HttpMethod.GET, UserCallBack);
public string get_data;
public string fbname;
void UserCallBack(FBResult result) {
if (result.Error != null)
{
get_data = result.Text;
}
else
{
get_data = result.Text;
}
var dict = Json.Deserialize(get_data) as IDictionary;
fbname =dict ["name"].ToString();
}
NOTE : display fbname using GUIText.
add this code to your script where u need username to be fetched, it will definitely help you .. comment your result so i can understand your problem clearly after this.. thank you.
Thanks Swa$$anonymous$$athan , that works , i can display the username after connecting to facebook in a GUIText.
Answer by pinunity · May 06, 2014 at 07:03 AM
you are a great help
using Facebook.MiniJSON;
please correct, thanks!!
Answer by mohanki · Dec 08, 2017 at 07:17 AM
Typed Callbacks
FBResult has been replaced. Method callbacks are now typed and have distinct result classes. For example: FB.API will return an IGraphResult and FB.Canvas.Pay will return an IPayResult. Refer to the call signature of each method to learn its result class.
Parsing callback results are simplified with the typed callbacks.
FB.API("/me?fields=first_name", HttpMethod.GET, delegate (IGraphResult result) {
// Add error handling here
if (result.ResultDictionary != null) {
foreach (string key in result.ResultDictionary.Keys) {
Debug.Log(key + " : " + result.ResultDictionary[key].ToString());
// first_name : Chris
// id : 12345678901234567
}
}
});
Your answer
Follow this Question
Related Questions
I can see/send invites to non-app user friends on canvas app but not on android/ios 0 Answers
Failed to build an apk after adding facebook SDK to unity3d project 0 Answers
Can't build for Android 0 Answers
Facebook SDK 3.1.2 for Unity - Trouble logging in on Android Devices 1 Answer
How do I correctly install the Facebook SDK plugin? 1 Answer