- Home /
Cant get public profile of real Facebook account but Test User by Using fackbook sdk & app42
Hello guys, I use fackbook sdk 7.2.1 and app42 for LeaderBoard in my project. 
First of all , I use Test User for test the code , it' work,I can get the name, picture....
When I use the real accounts for testing, the GetName() and GetPicture() of app42 cause error.
I can get the access token and useid but I cant get the name and the picture of the real Facebook account and the score is wrong.
Same problem in the devices. I dont know how to fix it.
FB login, share function is fine.
I use 3 plueins in my project app42 , facebook sdk , admob. What should I do?
Error Message : com.shephertz.app42.paas.sdk.csharp.App42Exception: System.NullReferenceException: Object reference not set to an instance of an object at ShowLeaderBoard.OnSuccess (System.Object response) [0x00259] in E:....
Sorry for my horrible english.
Answer by cyanogen8872 · Dec 24, 2015 at 04:38 PM
Is this problem caused by AndroidManifest? I combined the admob and facebook AndroidManifest. My AndroidManifest here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<!-- Google Mobile Ads Activity -->
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<!-- InAppPurchase Activity -->
<activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" android:theme="@style/Theme.IAPTheme" />
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.LoginActivity" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
<activity android:name="com.facebook.unity.AppInviteDialogActivity" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb223700171295186" />
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider223700171295186" android:exported="true" />
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>
</manifest>
If your test user is working right then it's probably nothing to do with this. See the answer I posted below for the more likely reasons: basically your Facebook app isn't published or you're using an incorrect player ID.
Answer by phil_me_up · Dec 24, 2015 at 01:58 PM
I've never used App42, so I can't comment on that specifically but if you login to developers.facebook.com and look at your app, is is set to "published"? If it's not then you will only be able to get the details of any "test users" you have set up.
Changing the Facebook app state to "Published" will allow you to get the details of actual logged in users (assuming the rest is setup correctly and you don't need additional approval).
Alternatively you can give the 'real user' a 'developer' or 'test' role within the Facebook app which should let you interact with that user properly before 'publishing' your Facebook app.
If you are already set to published and it's still not working, it might be because you are passing an invalid user ID. It's important to remember that when you connect a real user to an app, the user id you are given is specific to that user, for that app. So, for your app the user id might be 00123423432, but for another app the same user might have the id 00283729198. This is done for privacy reasons.
You therefore need to make sure that the UserID you are using is the one that Facebook returns to you after requesting a login (or at least one you know is valid for this particular appin the case of a friends ID) and not one that you've got from elsewere
Thank you for your reply.
About the "Published" option. In other to make my Facebook app state "published" , should I enable this setup only? Any other setting I should do so?

For the additional approval. I requested to read public_profile, user_friends and email permissions. Is it the problem caused by those permissions?
var perms = new List (){"email","public_profile","user_friends"}};
FB.LogInWithReadPermissions (perms, AuthCallback);
For the access token and userID. First, I request user to login. Then take the token and get name and picture.
FB.Init-->FB.LogInWithReadPermissions -->var aToken =
Facebook.Unity.AccessToken.CurrentAccessToken; ShowScoreBoard.userId=aToken.UserId; ShowScoreBoard.fbAcToken=aToken.TokenString;
----> take the userid to Save Score via a app42 function / -----> take the fbAcToken to get the rank , user name ,user picture via app42 funcions
You'll need to setup the app for the devices you're deploying on too (android I guess from your other comment), so just add that platform and fill in the gaps.
The permissions you are asking for are fine (see here for more info: https://developers.facebook.com/docs/facebook-login/permissions) but do you actually need "email"? Don't ask for it unless you're actually going to use it and the player can see why you want it (I would never allow a game to access my email address without good reason).
Your answer