3

Heroku で実行している Facebook アプリに不明な問題があります

問題はアクセストークンにあるものです。アプリ内の何かがアクセス トークンを破損しているように見えます。アプリにログインしようとしてエクスプローラーを使用すると、ログアウトしているか、アクセストークンの有効期限が切れていると表示されます。しかし、デバッグすると、さらに2時間有効であると表示されます。また、ログイン後にページをリロードできません。

どうやら、サイトはリロードし続けており、何度も更新されています。これは、ページにログインすると停止します

エラーは最近発生したようです.. 先週はありませんでした。問題はここのどこかにあると思いますが、見つかりません。問題を引き起こす可能性のあるものを見つけた場合は、ヒントを出してください。ありがとう

require_once('sdk/src/facebook.php');

$facebook = new Facebook(array(
 'appId'  => AppInfo::appID(), 
'secret' => AppInfo::appSecret(), 
'sharedSession' => true,
'trustForwarded' => true,
));

$user_id = $facebook->getUser();
if ($user_id) {
 try {
  // Fetch the viewer's basic information
    $basic = $facebook->api('/me');
 } catch (FacebookApiException $e) {
  // If the call fails we check if we still have a user. The user will be
// cleared if the error is because of an invalid accesstoken
 if (!$facebook->getUser()) {
  header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
  exit();
 }
}

 <script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '<?php echo AppInfo::appID(); ?>', // App ID
      channelUrl : '//<?php echo $_SERVER["HTTP_HOST"]; ?>/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true // parse XFBML
    });

   FB.getLoginStatus(function(response) {
    console.log (response.status);
    //this is useful if you want to avoid the infinite loop bug
    //it only reloads page when you log in
    if (response.status != 'connected') {
        FB.Event.subscribe('auth.login', function(response) {
            // We want to reload the page now so PHP can read the cookie that the
            // Javascript SDK sat. But we don't want to use
            // window.location.reload() because if this is in a canvas there was a
            // post made to this page and a reload will trigger a message to the
            // user asking if they want to send data again.
            window.location = window.location;
            //Im using the window.location.reload()
            //window.location.reload();
        });
    }
});
FB.Canvas.setAutoGrow();
 };

  // Load the SDK Asynchronously
  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));
</script>
<header class="clearfix">
  <?php if (isset($basic)) { ?>
  <p id="picture" style="background-image: url(https://graph.facebook.com/<?php echo he($user_id); ?>/picture?type=normal)"></p>

  <div>
    <h1>Welcome, <strong><?php echo he(idx($basic, 'name')); ?></strong></h1>
    <p class="tagline">
      This is your new app for sorting events
      <a href="<?php echo he(idx($app_info, 'link'));?>" target="_top"><?php echo he($app_name); ?></a>
    </p>

    <div id="share-app">
      <p>Share this app:</p>
      <ul>
        <li>
          <a href="#" class="facebook-button" id="postToWall" data-url="<?php echo AppInfo::getUrl(); ?>">
            <span class="plus">Post to Wall</span>
          </a>
        </li>
        <li>
          <a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>">
            <span class="speech-bubble">Send Message</span>
          </a>
        </li>
        <li>
          <a href="#" class="facebook-button apprequests" id="sendRequest" data-message="Prøv den her">
            <span class="apprequests">Send Requests</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
  <?php } else { ?>
  <div>
    <h1>Welcome</h1>
    <div class="fb-login-button" data-scope="user_likes,user_photos,user_events,friends_events, user_hometown,user_location,user_interests,user_about_me,user_education_history,friends_location,read_friendlists"></div> 
  </div>
  <?php } ?>
</header>
<section id="get-started">
 <?php 
 //echo (idx($app_get_events[1], 'id');
 ?>

</section>
4

1 に答える 1

0

どのブラウザを使用していますか?新しい Safari バージョンは、iframe からの Cookie を受け入れません。そのため、セッションが正常に機能しているかどうか、および Cookie を作成できるかどうかを確認してください。

于 2012-10-15T21:08:06.203 に答える