我剛開始用團結書寫我的第一個遊戲。Facebook使用Unity 5登錄 - 總是會返回我圖形API錯誤:錯誤的請求
我創建於Facebook應用程序 - 在遊戲類別。
我下載了Facebook idk並加入統一。 我在Facebook設置中更改了應用程序ID。
現在,我想我的代碼:
public class LoginScript : MonoBehaviour {
public string resultstr { get; set; }
public Text LableResult { get; set; }
List<string> perms = new List<string>(){"public_profile", "email", "user_friends"};
// Use this for initialization
void Start() {
LableResult = gameObject.GetComponent<Text>();
LableResult.text = "Test";
if (!FB.IsInitialized) {
// Initialize the Facebook SDK
FB.Init (InitCallback, OnHideUnity);
} else {
// Already initialized, signal an app activation App Event
FB.ActivateApp();
}
}
private void InitCallback()
{
if (FB.IsInitialized) {
// Signal an app activation App Event
FB.ActivateApp();
// Continue with Facebook SDK
// ...
} else {
Debug.Log ("Failed to Initialize the Facebook SDK");
}
}
private void OnHideUnity (bool isGameShown)
{
if (!isGameShown) {
// Pause the game - we will need to hide
Time.timeScale = 0;
} else {
// Resume the game - we're getting focus again
Time.timeScale = 1;
}
}
// Update is called once per frame
void Update() {
}
private void AuthCallback (ILoginResult result)
{
if (FB.IsLoggedIn) {
// AccessToken class will have session details
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
// Print current access token's User ID
Debug.Log (aToken.UserId);
// Print current access token's granted permissions
foreach (string perm in aToken.Permissions) {
Debug.Log (perm);
}
} else {
Debug.Log ("User cancelled login");
}
}
// On Facebook login button
public void OnFacebook()
{
FB.LogInWithReadPermissions (perms, AuthCallback);
}
}
但我總是在結果得到:
Graph Api Error: 400 Bad request
而且callback_id 2(有時我見過3)
登錄我嘗試在模擬窗口中使用來自Facebook的令牌。
我試圖部署在iPhone上 - 當我點擊登錄按鈕
感謝您的通知,這有助於我認識到,我用的應用程序令牌了。大聲笑 – nguyenhoai890