Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by zigglr · Apr 29, 2016 at 02:43 AM · unity 5facebookapi

Error using Facebook API to get user's birthday (given key not present in dictionary)

Hi, I have used the Facebook API to get the user's first name and gender fine, but when I try to also get their birthday. I get an error. Here is the code (It works fine for name and gender but not birthday):

     void AuthCallBack (IResult result)
     {
         if (result.Error != null)
         {
             Debug.Log(result.Error);
         }
 
         else
         {
             if (FB.IsLoggedIn)
             {
                 //Get Username, first parametre is what you want to get, method, callback
                 FB.API("/me?fields=first_name", HttpMethod.GET, DisplayUsername);
                 FB.API("/me?fields=gender", HttpMethod.GET, DisplayGender);
                 FB.API("/me?fields=birthday", HttpMethod.GET, DisplayBirthday);
 
                 SceneManager.LoadScene("loggedinpage");
             }
 
             else
             {
                 Debug.Log("not logged in");
             }
         }
     }
 
     void DisplayUsername (IResult result)
     {
         FacebookFirstName = result.ResultDictionary ["first_name"];
         Debug.Log(FacebookFirstName.ToString());
     }
 
     void DisplayGender(IResult result)
     {
         FacebookGender = result.ResultDictionary["gender"];
         Debug.Log(FacebookGender.ToString());
     }
 
 
     void DisplayBirthday(IResult result)
     {
         FacebookBirthday = result.ResultDictionary["birthday"];
         Debug.Log(FacebookBirthday.ToString());
     }
 
 }


And here is the error:

KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) facebook.DisplayBirthday (IResult result) (at Assets/Scripts/facebook.cs:104) Facebook.Unity.AsyncRequestString+c__Iterator1.MoveNext () (at Assets/FacebookSDK/SDK/Scripts/Utils/AsyncRequestString.cs:133)

Thanks a lot

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bastienmp · Jun 16, 2016 at 10:10 AM

Hello, Did you request for the birthday permission ? because the birthday is not include in the public_profile default permission, you have to request for user_birthday :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image babji3 · Apr 27, 2019 at 07:36 AM 0
Share
 $$anonymous$$eyNotFoundException: The given key was not present in the dictionary.
 System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
 Chat$$anonymous$$anager.GetInfoForChat (IResult result) (at Assets/GameWithFriends/Scripts/$$anonymous$$anagers/Chat$$anonymous$$anager.cs:113)
 FacebookExample$$anonymous$$anager.<AuthCallback>m__0 (IGraphResult LoginResult) (at Assets/GameWithFriends/Scripts/$$anonymous$$anagers/FacebookExample$$anonymous$$anager.cs:86)
 Facebook.Unity.AsyncRequestString+<Start>d__9.$$anonymous$$oveNext ()
 UnityEngine.SetupCoroutine.Invoke$$anonymous$$oveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
 

 private void GetInfoForChat(IResult result) 
     {
 
        UserID = result.ResultDictionary["id"].ToString();
         var dictionary = (Dictionary<string, object>)Facebook.$$anonymous$$iniJSON.Json.Deserialize(result.RawResult);
         var friendsDict = (Dictionary<string, object>)dictionary["friends"];
         var friendsList = (List<object>)friendsDict["data"];
         UserFriendsID = new List<string>();
         UserFriendsName = new Dictionary<string, string>();
         foreach (var dict in friendsList)
         {
             UserFriendsID.Add(((Dictionary<string, object>)dict)["id"].ToString());
             UserFriendsName.Add(((Dictionary<string, object>)dict)["id"].ToString(), ((Dictionary<string, object>)dict)["name"].ToString());
         }
         ///Start chat
         Connect();
     }

I got this error. Am using PUN with facebook to getting friends list

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

69 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How we create multiple leaderboard of facebook without using any other server? 1 Answer

Unity: Is there any alternative to facebook SDK for facebook ads attribution? 0 Answers

Unity Scripting API 1 Answer

unity Facebook For Android Error 0 Answers

android player error 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges