此代码取自Firebases网站上的文档,我只想弄清楚如何为Unity 3D进行简单的Twitter登录。
在网站上,第一步是使用Firebase进行身份验证是按照Android的说明操作的,但它全部使用JS而非C#,以获取OAuth访问令牌和OAuth密钥。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase.Auth;
using UnityEngine.UI;
public class TwitterLoginActivity : MonoBehaviour {
private FirebaseAuth auth;
// Use this for initialization
void Start () {
auth = FirebaseAuth.DefaultInstance;
}
// Update is called once per frame
void Update () {
Firebase.Auth.Credential credential =
Firebase.Auth.TwitterAuthProvider.GetCredential(accessToken, secret);
auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
if (task.IsCanceled)
{
Debug.LogError("SignInWithCredentialAsync was canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
return;
}
Firebase.Auth.FirebaseUser newUser = task.Result;
Debug.LogFormat("User signed in successfully: {0} ({1})",
newUser.DisplayName, newUser.UserId);
});
}
}
答案 0 :(得分:0)
你可以将twitter sdk整合到你的团结项目中。
好像是twitter没有团结的sdk, 你应该使用RESTFUL服务。