1
如果不使用任何UI /按鈕,如何使用Facebook的Android SDK請求Facebook應用的發佈權限?我目前使用這段代碼,但它註冊了兩次回調,給我重複的結果。請求發佈權限的正確方法是什麼?如何使用Facebook的Android SDK請求發佈權限?
List<String> basicPermissions = Arrays.asList("user_friends", "user_games_activity");
List<String> publishPermissions = Arrays.asList("publish_actions");
mCallbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().logInWithReadPermissions(this, basicPermissions);
LoginManager.getInstance().logInWithPublishPermissions(this, publishPermissions);
LoginManager.getInstance().registerCallback(mCallbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResults) {
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{my-app-id}/scores",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
// my code
}
}
).executeAsync();
}
@Override
public void onCancel() {
Log.e("dd","facebook login canceled");
}
@Override
public void onError(FacebookException e) {
Log.e("dd", "facebook login failed error");
}
});