https://github.com/GrioSF/AndroidFBPhotoPicker
我正在使用上述代码作为参考,但演示版也返回了相同的响应(专辑没有值)
提前致谢...
最佳答案
我使用以下代码从Facebook获取相册,它对我有用。
LoginButton loginButton=new LoginButton(MainActivity.this);
loginButton.setReadPermissions("email", "user_friends","user_photos");
loginButton.performClick();//call this method to your button click
private FacebookCallback<LoginResult> callback = new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
try {
// parse your JSON here....
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday,albums");
request.setParameters(parameters);
request.executeAsync();
AccessToken accessToken = loginResult.getAccessToken();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException e) {
}
};