我已經在我的應用程序中集成了Facebook登錄。它工作正常,並在回調方法,我得到獲取facebook用戶個人資料數據,android?
這是我的代碼
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_login);
findViewById(R.id.sign_in_button).setOnClickListener(this);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions("basic_info","user_friends","email");
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.e("res",""+loginResult.getAccessToken());
Toast.makeText(LoginActivity.this,""+loginResult.getAccessToken().getUserId(),Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
}
當我打印的訪問令牌,我得到
{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[user_friends, contact_email, email, public_profile, basic_info]}
我是如何得到用戶的尋找從FB PROFILE DATA
的方法,數據
GraphRequest request = GraphRequest.newMeRequest(
accessToken,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
request.executeAsync();
但它要求一個seeion。我從哪裏得到會議?
什麼是你想要獲得的所有數據? – Shadow 2015-03-31 10:06:27
你得到的錯誤是什麼? AccessToken是SDK v4中Session的替代品。 – 2015-03-31 18:20:50