我想设置代表用户在墙上发帖的权限。当用户使用 facebook 登录时,应该会出现一个对话框,如下所示。当用户点击确定时,他应该能够在他的帖子上发帖。
我试过这个....这是我的代码..请帮助我
LoginButton authButton = (LoginButton) findViewById(R.id.authButton);
authButton.setOnErrorListener(new OnErrorListener() {
@Override
public void onError(FacebookException error) {
Log.i(TAG, "Error " + error.getMessage());
}
});
// set permission list, Don't foeget to add email
authButton.setReadPermissions(Arrays.asList("basic_info","email","user_status"));
// session state call back event
authButton.setSessionStatusCallback(new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Log.i(TAG,"Access Token"+ session.getAccessToken());
postToWall();
Request.executeMeRequestAsync(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user,Response response) {
if (user != null) {
Log.i(TAG,"User ID "+ user.getId());
Log.i(TAG,"Email "+ user.asMap().get("email"));
// lblEmail.setText(user.asMap().get("email").toString());
String Email= (String) user.asMap().get("email");
Toast.makeText(getApplicationContext(), Email, Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), ShareCommentActivity.class);
startActivity(intent);
}
}
});
}
}
});
这是贴墙方法
@SuppressWarnings("deprecation")
public void postToWall() {
// post on user's wall.
facebook.dialog(this, "feed", new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onComplete(Bundle values) {
}
@Override
public void onCancel() {
}
});
提前致谢