让所有的照片在Android上使用Facebook的SDK用户的个人资料 [英] Getting all the photos in a user's profile using Facebook SDK on android
问题描述
我能使用Facebook的SDK 4.0 Android上使用它来获取用户的个人资料照片 -
I'm able to get profile photo of a user using Facebook SDK 4.0 on android using this -
loginButton = (LoginButton)findViewById(R.id.login_button);
profile = (ImageView)findViewById(R.id.profile);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
String userId = loginResult.getAccessToken().getUserId();
String imageUrl = String.format("https://graph.facebook.com/%s/picture?type=large", userId);
Picasso.with(getBaseContext()).load(imageUrl).into(profile);
}
}
如何去让所有的照片在用户的个人资料?任何帮助是AP preciated。
How to go about getting all the photos in a user's profile ? Any help is appreciated.
推荐答案
首先确保的accessToken有user_photos许可
Firstly Make sure the AccessToken has user_photos permission
然后在应用程序,调用一个GraphRequest有照片的{link}字段
Then on the app, call a GraphRequest with a photos{link} field
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
try {
//This contains all the photos with array data>>link
JSONObject photosobject = object.getJSONObject("photos");
} catch (Exception e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,picture,photos{link}");
request.setParameters(parameters);
request.executeAsync();
然后请参阅Facebook的图形API工具测试所需的值
<一href=\"https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me%3Ffields%3Dphotos%7Blink%7D\" rel=\"nofollow\">https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me%3Ffields%3Dphotos%7Blink%7D
注意:还要确保您有最新的FacebookSDK
Note: also make sure that you have the latest FacebookSDK
这篇关于让所有的照片在Android上使用Facebook的SDK用户的个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!