问题描述
编辑:Anwser在文章最后
我想获得一个Facebook用户的资料图片得益于内置的Facebook SDK的功能 请求()
我使用的是 / ME /图片
调用来获取个人资料图片,并将其转换成 位图
呼叫工作正常,但我不知道该如何跨preT和解析从Facebook返回的结果
下面是 JSON
,我得到的:
{FACEBOOK_NON_JSON_RESULT: " \u0000\u0010JFIF\u0000\u0001\u0002\u0000\u0000\u0001\u0000\u0001\u0000\u0000 \u0000\u0004*\u0000 \u0000C\u0000\u0006\u0004\u0005\u0006\u0005\u0004\u0006\u0006\u0005\u0006\u0007\u0007\u0006\b"}
我想这应该是重新presenting资料图片,但我不知道现在该怎么办这个问题。
如果有人能告诉我,无论怎样去code,它转换为位图或什么样的数据是,我将不胜感激。
注:我不希望使用任何其他功能比要求(),像德codeStream()或AsyncTask的
下面就是答案:
在做一个新的请求()
则需要将重定向参数添加到假
:
捆绑PARAMS =新包();
params.putBoolean(重定向,假);
这将返回正确的图片网址:
{
数据:{
is_silhouette:假的,
"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xpa1\/v\/t1.0-1\/p100x100\/10312434_10152395442477210_2933994167675146084_n.jpg?oh=f3c8cb920c97fcfa4dc5e17462445cbf&oe=54404A3A&__gda__=1412730795_5f288e34e5f6e63cb1c3791dcb142880"
}
}
GraphRequest picGraphRequest = GraphRequest.newGraphPathRequest(loginResult.getAccessToken(),/我/图片,新GraphRequest.Callback (){
@覆盖
公共无效onCompleted(GraphResponse graphResponse){
Log.d(TAG,graphResponse.getJSONObject()的toString());
}
});
捆绑picParameters =新包();
picParameters.putString(宽度,9999);
picParameters.putString(重定向,假);
picGraphRequest.setParameters(picParameters);
picGraphRequest.executeAsync();
背后保持宽度为9999的想法是让全分辨率图像。
EDIT: Anwser at the end of this post.
I am trying to get a Facebook user's profile picture thanks to the inbuilt Facebook SDK's function Request()
.
I am using a /me/picture
call to get the profile picture and convert it into a Bitmap
.
The call is working fine but I don't know how to interpret and parse the result returned from Facebook
Here is the JSON
that I get:
{"FACEBOOK_NON_JSON_RESULT" : "����\u0000\u0010JFIF\u0000\u0001\u0002\u0000\u0000\u0001\u0000\u0001\u0000\u0000��\u0000\u0004*\u0000��\u0000C\u0000\u0006\u0004\u0005\u0006\u0005\u0004\u0006\u0006\u0005\u0006\u0007\u0007\u0006\b"}
I think this should be representing the profile picture but I don't know what to do with this now.
If somebody could tell me either how to decode it, convert it to a Bitmap or what kind of data it is, I would be grateful.
NOTES: I don't want to use any other function than Request(), like DecodeStream() or an AsyncTask
Here is the answer:
When making a new Request()
you need to add the "redirect" parameter to false
:
Bundle params = new Bundle();
params.putBoolean("redirect", false);
This will return the correct picture URL:
{
"data":{
"is_silhouette":false,
"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xpa1\/v\/t1.0-1\/p100x100\/10312434_10152395442477210_2933994167675146084_n.jpg?oh=f3c8cb920c97fcfa4dc5e17462445cbf&oe=54404A3A&__gda__=1412730795_5f288e34e5f6e63cb1c3791dcb142880"
}
}
GraphRequest picGraphRequest = GraphRequest.newGraphPathRequest(loginResult.getAccessToken(), "/me/picture", new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
Log.d(TAG, graphResponse.getJSONObject().toString());
}
});
Bundle picParameters = new Bundle();
picParameters.putString("width", "9999");
picParameters.putString("redirect", "false");
picGraphRequest.setParameters(picParameters);
picGraphRequest.executeAsync();
The idea behind keeping width as 9999 is to get the full resolution image.
这篇关于Android的&放大器; Facebook的SDK:从解码图片/ ME /图片图表电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!