[英]Issue About Facebook SDK. Is Facebook Image URL Change Each Login ? How To Get Image URL and Facebook ID From Facebook SDK 7.9 In Unity C#?
我正在搜索一些有关从facebok sdk获取url的线程。 但是我还是不明白它是如何工作的。 我怀疑最新的Facebook SDK 7.9是否相同。
URL Facebook Image每次登录是否始终相同? 否则它将改变? 如果始终相同,则可以将其存储到数据库中,并且可以根据需要调用,而无需再次获取该URL。
和
在facebook SDK 7.9中,我找不到任何调用facebook ID的函数。 FB.AppId是Facebook用户ID吗?
每次登录时,Facebook ID总是一样吗?
我需要在排行榜中显示所有图片Facebook。 因此,我需要来自Facebook的图片网址。
最好的方法是什么?
如何检索可以保存到数据库的图像URL?
还是有什么如果我们可以获取Facebook ID或拥有Facebook ID,即使我们没有登录也可以从Facebook ID调用图像URL?
有人可以向我解释吗?
谢谢
丹尼斯
只需使用以下代码即可检索当前的个人资料图片:
FB.API("/me/picture?redirect=false", HttpMethod.GET, ProfilePhotoCallback);
private void ProfilePhotoCallback (IGraphResult result)
{
if (string.IsNullOrEmpty(result.Error) && !result.Cancelled) {
IDictionary data = result.ResultDictionary["data"] as IDictionary;
string photoURL = data["url"] as string;
StartCoroutine(fetchProfilePic(photoURL));
}
}
private IEnumerator fetchProfilePic (string url) {
WWW www = new WWW(url);
yield return www;
this.profilePic = www.texture;
//Construct a new Sprite
Sprite sprites = new Sprite();
//Create a new sprite using the Texture2D from the url.
//Note that the 400 parameter is the width and height.
//Adjust accordingly
sprite = Sprite.Create(www.texture, new Rect(0, 0, 50 ,50), Vector2.zero);
sprites = Sprite.Create(www.texture, new Rect(0, 0, 50 ,50), Vector2.zero);
}
并且要检索其他玩家资料图片,您必须首先知道用户ID。
这是检查用户ID的代码:
Facebook.Unity.AccessToken.CurrentAccessToken.UserId
之后使用:
FB.API ("/" + userid + "/picture?redirect=false", HttpMethod.GET, ProfilePhotoCallback);
检索所选的用户ID个人资料图片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.