从Facebook Graph API获取个人资料图片的问题

问题描述 投票:2回答:3

已经奠定了基础,但现在,发现自己想要玩我的 应用程序的用户个人资料图片;我很难过......已经有好几个小时......

首先,使用官方(虽然阿尔法;-)获得我的oauth_token / access_token Facebook C# SDK并且仅使用Graph API

FBapi.Get(“/”+ friend.Dictionary [“id”]。String +“/ picture”);

由于没有返回JSONObject而导致异常,并且

使用完整的http://graph.facebook.com/me/picture被转发/翻译成图像的URL。

尝试更直接的方法也没有成功:

WebClient wcImg = new WebClient();

wcImg.DownloadFile(“/”+ friend.Dictionary [“id”]。String +“/ picture”,“name_blame.jpg”);

我的问题中缺少一些细节;请原谅,我很累,如果骚动开始,我会稍后编辑。

想法?


Addendum : Boy, afflicted by code blindness I was indeed! However, your sensibility gave me what I needed (Zynga, tremble in my canvas ;-).

为了好奇......似乎没有可用于个人资料图片的JSON模板(原谅我缺乏语言)?然后如何获得该配置文件图片(如果可用)的图片API照片?

c# .net facebook social-graph
3个回答
4
投票

Graph API中的图片有点特殊。它不返回json,它直接转发到图像。这样做是为了你可以在html中使用这个url:

<img src="http://graph.facebook.com/<UID>/picture"> - displays avatar

现在,如果你需要知道实际的图片网址,它会重定向到有两个选项:

  1. 从该图表URL中读取重定向标题。
  2. 使用FQL: select pic_square from user where uid=12345

关于使用FQL的用户(包括其他尺寸的图片),可以提取很多其他信息。


3
投票

此外,如果您想要显示大型个人资料照片,请使用以下内容:

http://graph.facebook.com/<UID>/picture?type=large

1
投票

您可以在一个GET请求中获取所有朋友的个人资料照片(直接链接到照片):

https://graph.facebook.com/me/friends?access_token=[oauth_token]&fields=name,id,picture

然后使用Json解码字符串..这就是全部......

NJoy ^ _ ^

© www.soinside.com 2019 - 2024. All rights reserved.