从 Facebook Graph API 获取个人资料图片时出现问题
已经奠定了基础,但现在,我发现自己想玩弄我的
应用程序用户的个人资料图片;我很困惑......并且已经好几个小时了......
首先,使用官方获取了我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Graph API 中的图片是一个有点特殊的动物。它不返回json,而是直接转发到图像。这样做是为了让您可以在 html 中直接使用此 url:
现在,如果您需要知道实际的图片 URL,它会重定向到有 2 个选项:
使用 FQL:
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:
Now if you need to know actual picture URL it redirects to there are 2 options:
Use FQL:
There is alot of other info that can be extracted about a user using FQL (including pictures in other sizes).
另外,如果您想显示大个人资料照片,请使用以下命令:
Also, if You want to show big profile photo, use this:
您可以在单个 GET 请求中获取所有朋友的个人资料图片(直接链接到照片):
然后使用 Json 解码字符串..仅此而已...
NJoy ^_^
You can get ALL friends' profile pictures (direct Links to the photos), in a single GET request:
Then use Json to Decode the string.. and that's all...
NJoy ^_^