facebookLoginbutton = (Loginbutton)vIEw .findVIEwByID(R.ID.fragment_login_facebook); facebookLoginbutton.setFragment(this);callbackManager = CallbackManager.Factory.create();facebookLoginbutton.setReadPermissions(Arrays.asList("public_profile","email","user_birthday","user_frIEnds")); callbackManager = CallbackManager.Factory.create(); facebookLoginbutton.registerCallback(callbackManager,new FacebookCallback<LoginResult>() { private ProfileTracker mProfileTracker; @OverrIDe public voID onSuccess(LoginResult loginResult) { String accesstocken = loginResult.getAccesstoken().getToken().toString(); Log.v("TAG","Access Token " + loginResult.getAccesstoken().getToken()); GraphRequest request = GraphRequest.newMeRequest( loginResult.getAccesstoken(),new GraphRequest.GraphJsONObjectCallback() { @OverrIDe public voID onCompleted(JsONObject object,GraphResponse response) { try { String email = object.getString("birthday"); String name = object.getString("gender"); Toast.makeText(getActivity().getApplicationContext(),email + " " + name,Toast.LENGTH_SHORT).show(); } catch (JsONException e) { e.printstacktrace(); } } }); Bundle parameters = new Bundle(); parameters.putString("fIElds","ID,name,email,gender,birthday"); request.setParameters(parameters); request.executeAsync(); if (com.facebook.Profile.getCurrentProfile() == null){ mProfileTracker = new ProfileTracker() { @OverrIDe protected voID onCurrentProfileChanged(com.facebook.Profile oldProfile,com.facebook.Profile currentProfile) { mProfileTracker.stopTracking(); } }; mProfileTracker.startTracking(); } else { com.facebook.Profile profile = com.facebook.Profile.getCurrentProfile(); } try { URL image_value = new URL("http://graph.facebook.com/" + loginResult.getAccesstoken().getUserID() + "/picture?type=large"); Log.v(Constants.TAG,image_value + ""); } catch (Exception e) { } } @OverrIDe public voID onCancel() { Log.e("TAG","wrong"); } @OverrIDe public voID onError(FacebookException error) { Log.e("TAG","wrong"); } });
其中facebookLoginbutton是Loginbutton,callbackManager是CallbackManager
请提前帮助我.
Apps that Require App RevIEw
Your app requires revIEw if it uses the following functionality:
Facebook Login and also asks for a person’s birthday,location,hometown,age range,or link to profile
>查看link以获取更多详细信息.
总结以上是内存溢出为你收集整理的如何在Android中从Facebook获取用户性别和生日全部内容,希望文章能够帮你解决如何在Android中从Facebook获取用户性别和生日所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)