gpt4 book ai didi

android - 获取页面个人资料图片Graph API android

转载 作者:行者123 更新时间:2023-11-29 00:06:33 24 4
gpt4 key购买 nike

我想获取页面的个人资料图片。这是代码,但我不知道如何获取图像:

new GraphRequest(AccessToken.getCurrentAccessToken(), 
"/174034509278825/picture",
null,
HttpMethod.GET,
new GraphRequest.Callback()
{
public void onCompleted(GraphResponse response) {
try { }
catch (JSONException e)
{
e.printStackTrace();
}
}

}
).executeAsync();

最佳答案

获取头像的响应json :

{
"data": {
"is_silhouette": false,
"url": "picture-url"
},
}

我的解决方案代码:

   AccessToken accessToken = new AccessToken({access-token}
, {app-id}, {user-id}
, null, null, null, null, null);

GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/{user-id}/picture",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
try {
JSONObject responseJSONObject = response.getJSONObject();
JSONObject data = responseJSONObject.getJSONObject("data");

Log.i("your tag", "picture url = "+data.getString("url"));
} catch (JSONException e) {
e.printStackTrace();
}
}
});

Bundle parameters = new Bundle();
parameters.putString("redirect", "false");
request.setParameters(parameters);
request.executeAsync();

关于android - 获取页面个人资料图片Graph API android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33385714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com