0

我正在开发一个带有 facebook 登录的 android 应用程序

但 facebook getuser 有时会返回 0 我发现java.lang.NullPointerException

$facebook = new Facebook(array(
  'appId'  => 'xxxx',
  'secret' => 'xxxx',
cookie : false));

$facebook->setAccessToken($token);

$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
    $id = isset($user_profile['id']) ?
        $user_profile['id'] : ResultError(ERROR_INVALID);
    $name = isset($user_profile['name']) ? $user_profile['name'] : '';
    $email = isset($user_profile['email']) ? $user_profile['email'] : '';
    $gender = isset($user_profile['gender']) ? $user_profile['gender'] : '';
    $birth_date = isset($user_profile['birthday']) ?
        date("Y-m-d" , strtotime($user_profile['birthday'])) : '';
    $region = isset($user_profile['location']['name']) ?
        $user_profile['location']['name'] : '';
  } catch (FacebookApiException $e) {
      error_log($e);
      $user=null;

这是堆栈

    java.lang.NullPointerException
    at com.stamproad.stamproad.subroad.StorePagerAdapter$7.onClick(StorePagerAdapter.java:467)
    at android.view.View.performClick(View.java:4084)
    at android.view.View$PerformClick.run(View.java:16966)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
4

0 回答 0