Facebook OAuthException: (#1)

后端 未结 2 419
误落风尘
误落风尘 2021-01-13 15:09

I have a few applications which upload image to user profile. A few hours ago all applications were working fine but now when uploading is requested, it gives this error

相关标签:
2条回答
  • 2021-01-13 15:15

    You need to verify if the user is logged in AND has the permissions to post on wall. We're going to do that with a TRY/CATCH with a call to the user.

    $userId = $facebook -> getUser();
    
    if ($userId) {
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
          $userId = NULL;
          error_log($e);
      }
    }
    
    $app_permissions = array(
      'scope' => 'publish_stream'
      );
    
    $logoutUrl = $facebook->getLogoutUrl();
    $loginUrl = $facebook->getLoginUrl($app_permissions);
    

    If the user is not logged in OR has authorized the app, you'll need to redirect him via header redirect or with a link.

    if ($userId){
        //Then you can call the facebook api
        $data = $facebook->api('/'.$uid.'/photos', 'post', $args);
        //... ...
    }
    

    That's the easiest way i've found.

    EDIT : This question on stack has helped me : Facebook PHP SDK Upload Photos

    0 讨论(0)
  • 2021-01-13 15:26

    No, the error is caused by the system cannot get the image file. Facebook will not allow the empty image field appear in the api. So it return Fatal error: Uncaught OAuthException: (#1) --- although it does not relate to the OAuth and OAuthException.

    0 讨论(0)
提交回复
热议问题