从 Facebook Graph API 获取个人资料图片时出现问题

发布于 2024-09-24 17:26:13 字数 1124 浏览 5 评论 0原文

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

首先,使用官方获取了我的 oauth_token / access_token (尽管是 Alpha ;-)
Facebook C# SDK 并且仅使用图形 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 模板(请原谅我缺乏行话)?那么如何获取该个人资料图片的充实的 Graph API 照片(如果有)?

Have gotten the foundation in place, but now, finding myself wanting to play around with my
application's user's profile pictures; I'm stumped....and have been for quite some hours...

Firstly, my oauth_token / access_token is obtained, using the official (though Alpha ;-)
Facebook C# SDK and only utilize the Graph API.

FBapi.Get("/" + friend.Dictionary["id"].String + "/picture");

leads to an exception due to not returning a JSONObject, and

using the complete http://graph.facebook.com/me/picture is forwarded/translated to the image's URL.

Trying a more direct approach didn't pan out either :

WebClient wcImg = new WebClient();

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

Some details are lacking in my question; I beg your pardon, am very tired and will edit later if uproar commences.

Ideas?


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

For sake of curiosity...it appears there's no JSON template(pardon my lack of lingo) available for profile pictures? Then how do one go about obtaining a fleshed out, Graph API Photo of that profile picture (if available)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我很坚强 2024-10-01 17:26:13

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

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

现在,如果您需要知道实际的图片 URL,它会重定向到有 2 个选项:

  1. 从该图形 URL 读取重定向标头。
  2. 使用 FQL:

    从 uid=12345 的用户中选择 pic_square
    

FQL 可以提取有关用户的许多其他信息(包括其他尺寸的图片)。

The picture in Graph API is a bit special animal. It doesn't return json, it directly forwards to the image. It was made so that you can use this url right in html:

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

Now if you need to know actual picture URL it redirects to there are 2 options:

  1. Read redirect headers from that graph URL.
  2. Use FQL:

    select pic_square from user where uid=12345
    

There is alot of other info that can be extracted about a user using FQL (including pictures in other sizes).

枉心 2024-10-01 17:26:13

另外,如果您想显示大个人资料照片,请使用以下命令:

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

Also, if You want to show big profile photo, use this:

http://graph.facebook.com/<UID>/picture?type=large
违心° 2024-10-01 17:26:13

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

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

然后使用 Json 解码字符串..仅此而已...

NJoy ^_^

You can get ALL friends' profile pictures (direct Links to the photos), in a single GET request:

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

Then use Json to Decode the string.. and that's all...

NJoy ^_^

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文