简体   繁体   中英

Facebook getuser return 500 internal error in PHP SDK

I have this type of problem i use the PHP SDK latest version , and from march my application is stopped when i must done the login. I have done the upload of the latest version but now when php execute

$user = $facebook->getUser();

I obtain error 500 internal etc. etc. . I have tried everythings, but now i don't know what's the problem, i have also tried with Facebook PHP SDK 500 - Internal server error

but i obtain only internal error. If someone can help me. The Code is this

<?php

    require 'src/facebook.php';

    $facebook = new Facebook(array(
      'appId'  => 'fdsafdasfdasfdsafas8',
      'secret' => 'dasgasgasgasgas',
    ));

    // See if there is a user from a cookie
    $user = $facebook->getUser();

    if ($user) {
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
        $user = null;
      }
    }

    ?>
    <!DOCTYPE html>
    <html xmlns:fb="http://www.facebook.com/2008/fbml">
      <body>
        <?php if ($user) { ?>
          Your user profile is
          <pre>
            <?php print htmlspecialchars(print_r($user_profile, true)) ?>
          </pre>
        <?php } else { ?>
          <fb:login-button></fb:login-button>
        <?php } ?>
        <div id="fb-root"></div>
        <script>
          window.fbAsyncInit = function() {
            FB.init({
              appId: '<?php echo $facebook->getAppID() ?>',
              cookie: true,
              xfbml: true,
              oauth: true
            });
            FB.Event.subscribe('auth.login', function(response) {
              window.location.reload();
            });
            FB.Event.subscribe('auth.logout', function(response) {
              window.location.reload();
            });
          };
          (function() {
            var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol +
              '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
          }());
        </script>
      </body>
    </html>

您可能需要启用ssl库,也可以检查Apache日志中的错误

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM