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
2
Question by mubeeniqbal · Jul 27, 2017 at 07:20 AM · androideditorfacebookmacsdk

Facebook SDK IGraphResult is returning null values in Unity 2017.1.0f3

I have some code which loads the user profile picture from Facebook using the Facebook SDK.

 private void GetProfilePicture(string userId)
 {
     FB.API(userId + "/picture?width=256&height=256", HttpMethod.GET, OnGetProfilePicture);
 }

 private void OnGetProfilePicture(IGraphResult result)
 {
     Debug.Log(result.RawResult);

     if (result.Error == null) // Success
     {
         Texture2D texture = result.Texture;
         texture.name = "ProfilePicture";
         DispatchResponse(SocialServiceResult.SUCCESS, texture);
     }
     else // Failure
     {
         DispatchResponse(SocialServiceResult.FAILURE, null);
     }
 }

The exact same codebase used to work perfectly fine in the previous version of Unity i.e. 5.6.2. I have tested the codebase both on the editor and the device (Android) but the issue remains. Just for reference here is what I get on the editor console on logging failure:

 Unable to get the profile picture. SocialServiceResult: FAILURE
 UnityEngine.Debug:LogWarning(Object)
 TurboLabz.Gamebet.Logger:LogWarning(Object) (at Assets/Common/Scripts/Utils/Static/Logger.cs:39)
 TurboLabz.Gamebet.GetPlayerProfilePictureCommand:OnGetProfilePicture(SocialServiceResult, 
 Texture2D) (at Assets/Gamebet/Scripts/Controllers/GetPlayerProfilePictureCommand.cs:61)
 strange.extensions.promise.impl.Promise`2:CallListener() (at Assets/Strange/extensions/promise/impl/Promise.cs:205)
 strange.extensions.promise.impl.Promise`2:Dispatch(SocialServiceResult, Texture2D) (at Assets/Strange/extensions/promise/impl/Promise.cs:165)
 TurboLabz.Gamebet.FBGetProfilePictureRequest:DispatchResponse(SocialServiceResult, Texture2D) (at Assets/Gamebet/Scripts/Services/Facebook/FBRequests/FBGetProfilePictureRequest.cs:104)
 TurboLabz.Gamebet.FBGetProfilePictureRequest:OnGetProfilePicture(IGraphResult) (at Assets/Gamebet/Scripts/Services/Facebook/FBRequests/FBGetProfilePictureRequest.cs:98)
 Facebook.Unity.<Start>d__9:MoveNext()
 UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

I also checked the values of the different variables. The value of result.Error is an empty string; it is not null. The value of result.Texture is null. On logging the value of result.RawResult the editor console shows:

 ����
 UnityEngine.Debug:Log(Object)
 TurboLabz.Gamebet.Logger:Log(Object) (at Assets/Common/Scripts/Utils/Static/Logger.cs:29)
 TurboLabz.Gamebet.FBGetProfilePictureRequest:OnGetProfilePicture(IGraphResult) (at Assets/Gamebet/Scripts/Services/Facebook/FBRequests/FBGetProfilePictureRequest.cs:99)
 Facebook.Unity.<Start>c__Iterator0:MoveNext()
 UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

That looks like some garbage value inside result.RawResult.

Another thing worth mentioning is that I can log into my game perfectly fine with using Facebook SDK; no issues there. It's just the profile picture that has become an issue.

This problem started occurring after upgrading Unity to 2017.1.0f3 (64bit) on the very same codebase that I had earlier. I am running Unity on macOS Sierra. Facebook SDK version is 7.9.4 (I also upgraded to Facebook SDK version 7.10.0 but no luck).

Does anybody have any idea what could be the problem? Or is it a bug in Unity/Facebook SDK?

Thanks in advance.

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
1

Answer by Jasr_88 · Jul 28, 2017 at 03:38 AM

Hello, You might make the request this way:

 FB.API(userId + "/picture?width=256&height=256&redirect=false"....

This way you'r responce won't be empty, for furter information of how to get the texture of the profile picture, you can see this post

http://answers.unity3d.com/questions/1074298/new-facebook-sdk-fot-unity-70-loading-a-profile-pi.html

i hope you will find this information useful Sorry for the bad english.

Comment
Add comment · Show 4 · 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 mubeeniqbal · Jul 29, 2017 at 09:36 AM 1
Share

Thanks for the answer. This seems like a bug patch to me rather than a proper solution. Adding redirect=false did indeed return me a response but now it sends the image url ins$$anonymous$$d of the texture itself. This means that I'll have to retrieve the image myself in another call. However, my question really is that why has the texture retrieval stopped working all of a sudden? Is it a bug on Facebook's end? Ideally I would want to use result.Texture to simply get the image.

avatar image mubeeniqbal · Jul 29, 2017 at 09:46 AM 0
Share

Another question: For the response to be error free should I just check result.Error == null or should I check for string.IsNullOrEmpty(result.Error)? Can a valid response ever have an empty string error or will it always be null?

avatar image mubeeniqbal mubeeniqbal · Jul 31, 2017 at 10:19 AM 1
Share

So I figured it out for the error. Digging into the Facebook Unity SD$$anonymous$$ source here I found this comment: "If no error occurred value is null or empty." So the right check would be string.IsNullOrEmpty(result.Error). Thought this could be of help to others.

avatar image aitc mubeeniqbal · Aug 01, 2017 at 06:41 AM 0
Share

Thanks for your info.

Ins$$anonymous$$d of using

if (result.Error != null)

I use if (!string.IsNullOrEmpty(result.Error)) help me fix the error.

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

150 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 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 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

Facebook Login - Android 1 Answer

Facebook Android Studio 0 Answers

Facebook SDK(android) - error 1 Answer

Game Analytics & Facebook sdk android build error 1 Answer

D8: Program type already present: com.facebook.unity.Constants 2 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