2012-03-13 9 views
0

私はherokuによって提供されるデフォルトのアプリケーションを編集しています。これは私のログインで動作します。しかし、他のユーザーは、アプリが動作しているとは見ません。私のアプリは許可が必要です - user_relationships、friends_relationships。アプリは他のユーザーにのみ動作しますが、他のユーザーには使用できません

ユーザーが見たaccess_tokenをデバッグすると、上記のアクセス許可が正しく指定されます。

誰かが問題点を教えていただけますか?前もって感謝します。

<?php 

// Provides access to app specific values such as your app id and app secret. 
// Defined in 'AppInfo.php' 
require_once('AppInfo.php'); 

// Enforce https on production 
if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') { 
header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 
exit(); 
} 

// This provides access to helper functions defined in 'utils.php' 
require_once('utils.php'); 


/**************************************************************************** 
* 
* The content below provides examples of how to fetch Facebook data using the 
* Graph API and FQL. It uses the helper functions defined in 'utils.php' to 
* do so. You should change this section so that it prepares all of the 
* information that you want to display to the user. 
* 
****************************************************************************/ 

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

// Instantiating Facebook object to access SDK 
$facebook = new Facebook(array(
'appId' => AppInfo::appID(), 
'secret' => AppInfo::appSecret(), 
)); 

// Returns facebook user id of the current user 
$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(); 
} 
} 

$access_token = $facebook->getAccessToken(); 
echo $access_token; 
// Here is an example of a FQL call that fetches all of your friends that are 
// using this app 
$app_using_friends = $facebook->api(array(
'method' => 'fql.query', 
'query' => 'SELECT uid, name, relationship_status FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())' 
)); 

} 

// Fetch the basic info of the app that they are using 
$app_info = $facebook->api('/'. AppInfo::appID()); 

$app_name = idx($app_info, 'name', ''); 

?> 
<!DOCTYPE html> 
<html xmlns:fb="http://ogp.me/ns/fb#" lang="en"> 
<head> 
<meta charset="utf-8" /> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" /> 

<title><?php echo he($app_name); ?></title> 
<link rel="stylesheet" href="stylesheets/screen.css" media="Screen" type="text/css" /> 
<link rel="stylesheet" href="stylesheets/mobile.css" media="handheld, only screen and (max-width: 480px), only screen and (max-device-width: 480px)" type="text/css" /> 

<!--[if IEMobile]> 
<link rel="stylesheet" href="mobile.css" media="screen" type="text/css" /> 
<![endif]--> 

<!-- These are Open Graph tags. They add meta data to your --> 
<!-- site that facebook uses when your content is shared  --> 
<!-- over facebook. You should fill these tags in with  --> 
<!-- your data. To learn more about Open Graph, visit  --> 
<!-- 'https://developers.facebook.com/docs/opengraph/'  --> 
<meta property="og:title" content="<?php echo he($app_name); ?>" /> 
<meta property="og:type" content="website" /> 
<meta property="og:url" content="<?php echo AppInfo::getUrl(); ?>" /> 
<meta property="og:image" content="<?php echo AppInfo::getUrl('/logo.png'); ?>" /> 
<meta property="og:site_name" content="<?php echo he($app_name); ?>" /> 
<meta property="og:description" content="My first app" /> 
<meta property="fb:app_id" content="<?php echo AppInfo::appID(); ?>" /> 

<script type="text/javascript" src="/javascript/jquery-1.7.1.min.js"></script> 

<script type="text/javascript"> 
    function logResponse(response) { 
    if (console && console.log) { 
     console.log('The response was', response); 
    } 
    } 

    $(function(){ 
    // Set up so we handle click on the buttons 
    $('#postToWall').click(function() { 
     FB.ui(
     { 
      method : 'feed', 
      link : $(this).attr('data-url') 
     }, 
     function (response) { 
      // If response is null the user canceled the dialog 
      if (response != null) { 
      logResponse(response); 
      } 
     } 
    ); 
    }); 

    $('#sendToFriends').click(function() { 
     FB.ui(
     { 
      method : 'send', 
      link : $(this).attr('data-url') 
     }, 
     function (response) { 
      // If response is null the user canceled the dialog 
      if (response != null) { 
      logResponse(response); 
      } 
     } 
    ); 
    }); 

    $('#sendRequest').click(function() { 
     FB.ui(
     { 
      method : 'apprequests', 
      message : $(this).attr('data-message') 
     }, 
     function (response) { 
      // If response is null the user canceled the dialog 
      if (response != null) { 
      logResponse(response); 
      } 
     } 
    ); 
    }); 
    }); 
</script> 

<!--[if IE]> 
    <script type="text/javascript"> 
    var tags = ['header', 'section']; 
    while(tags.length) 
     document.createElement(tags.pop()); 
    </script> 
<![endif]--> 
</head> 
<body> 
<div id="fb-root"></div> 
<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 
    //oauth  : true, 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 

//FB.login({ 
    //  scope : 'user_relationships,friends_relationships' 
    // }); 

    // Listen to the auth.login which will be called when the user logs in 
    // using the Login button 
    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; 
    }); 

    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 my app. My First Facebook app. 
     <a href="<?php echo he(idx($app_info, 'link'));?>" target="_top"><?php echo he($app_name); ?></a> 
    </p> 

    <div id="share-app"> 
    </div> 
    <?php } else { ?> 
    <div> 
    <h1>Welcome</h1> 
    <div class="fb-login-button"  data-scope="user_likes,user_photos,user_relationships,friends_relationships"></div> 
    </div> 
    <?php } ?> 
    </header> 

    <?php 
    if ($user_id) { 
    ?> 

var $shaheeds = 0; 
var $aazaads = 0; 
var $confused = 0; 
var $in_trap = 0; 
var $total = 0; 

    <section id="samples" class="clearfix"> 
    <h1>Examples of the Facebook Graph API</h1> 

    <div class="list"> 
    <h3>Shaheed Friends</h3> 
    <ul class="shaheed"> 
     <?php 
     foreach ($app_using_friends as $friend) { 
      // Extract the pieces of info we need from the requests above 
      $id = idx($friend, 'uid'); 
      $name = idx($friend, 'name'); 
     $r_status = idx($friend, 'relationship_status'); 
     if($r_status == "Married"){ 
      $shaheeds++; 
     ?> 
     <li> 
     <a href="https://www.facebook.com/<?php echo he($id); ?>" target="_top"> 
      <img src="https://graph.facebook.com/<?php echo he($id) ?>/picture?type=square" alt="<?php echo he($id); ?>"> 
      <?php echo he($name); ?> 
     </a> 
     </li> 
     <?php 
     } 
     } 
     ?> 
    </ul> 
    </div> 

    <div class="list inline"> 
    <h3>Recent photos</h3> 
    <ul class="photos"> 
     <?php 
     $i = 0; 
     foreach ($photos as $photo) { 
      // Extract the pieces of info we need from the requests above 
      $id = idx($photo, 'id'); 
      $picture = idx($photo, 'picture'); 
      $link = idx($photo, 'link'); 

      $class = ($i++ % 4 === 0) ? 'first-column' : ''; 
     ?> 
     <li style="background-image: url(<?php echo he($picture); ?>);" class="<?php echo $class; ?>"> 
     <a href="<?php echo he($link); ?>" target="_top"></a> 
     </li> 
     <?php 
     } 
     ?> 
    </ul> 
    </div> 

    <div class="list"> 
    <h3>Friends In Trap</h3> 
    <ul class="in-trap"> 
     <?php 
     foreach ($app_using_friends as $friend) { 
      // Extract the pieces of info we need from the requests above 
      $id = idx($friend, 'uid'); 
      $name = idx($friend, 'name'); 
     $r_status = idx($friend, 'relationship_status'); 
     if($r_status == "Engaged" || $r_status == "In a relationship"){ 
      // This display's the object that the user liked as a link to 
      // that object's page. 
    $in_trap++; 
     ?> 
     <li> 
     <a href="https://www.facebook.com/<?php echo he($id); ?>" target="_top"> 
      <img src="https://graph.facebook.com/<?php echo he($id) ?>/picture?type=square" alt="<?php echo he($name); ?>"> 
      <?php echo he($name); ?> 
     </a> 
     </li> 
     <?php 
     } 
     } 
     ?> 
    </ul> 
    </div> 

    <div class="list"> 
    <h3>Azaad Friends</h3> 
    <ul class="friends"> 
     <?php 
     foreach ($app_using_friends as $auf) { 
      // Extract the pieces of info we need from the requests above 
      $id = idx($auf, 'uid'); 
      $name = idx($auf, 'name'); 
     $r_status = idx($auf, 'relationship_status'); 
     if($r_status == "Single"){ 
      $aazaads++; 
     ?> 
     <li> 
     <a href="https://www.facebook.com/<?php echo he($id); ?>" target="_top"> 
      <img src="https://graph.facebook.com/<?php echo he($id) ?>/picture?type=square" alt="<?php echo he($name); ?>"> 
      <?php echo he($name); ?> 
     </a> 
     </li> 
     <?php 
     } 
     $total++; 
     } 
    $confused = $total - $aazaads - $shaheeds - $in_trap; 
     ?> 
    </ul> 
    </div> 
    </section> 
<section id="graphs" class="clearfix"> 
<h1>"Graph"</h1> 
<img src="http://chart.apis.google.com/chart?cht=p3&chd=t:<?php echo he($shaheeds)?>,<?php echo he($aazaads)?>,<?php echo he($in_trap)?>,<?php echo he($confused)?>&chs=250x100&chl=Shaheed|Aazaad|In Trap|Unknown" /> 
</section> 

    <?php 
    } 
    ?> 

    </body> 
    </html> 

答えて

1

同じ問題が発生しています。この1つのことは、​​モードを無効にする必要があることを確信しています。そのためにはFacebookのデベロッパーアプリに行ってください。そしてそれは進歩した。しかし、私は問題に直面しています。​​モードを無効にするためには、プライバシーポリシーのURLと安全なキャンバスのページURLを指定する必要があります。

関連する問題