0

我在 Facebook 应用程序上遇到问题。当任何人输入应用程序网址时,我想制作一个扇形门,例如。apps.facebook.com/zoomcompetition/

我无法在选项卡上显示它,因为它显示为空白。但它适用于应用程序网址,所以我想在应用程序指定上添加扇门到 Facebook 页面。这是代码

<?php

require 'src/facebook.php';
//require 'fbconfig.php';
require 'functions.php';

// Create An instance of our Facebook Application.
$facebook = new Facebook(array(
'appId' => ***************,
'secret' => **************,
));

// Get the app User ID
$user = $facebook->getUser();
if ($user) {
try {
// If the user is authenticated and logged-in
$user_profile = $facebook->api('/me');
//var_dump($user_profile);
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}

// If the user is authenticated then generate the variable for the logout URL
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();

?>

<!-- Insert Logged in HTML here -->
 <a href="<?php echo $logoutUrl; ?>">Logout</a>


 <?php
//Always place this code at the top of the Page

session_start();

if (!isset($_SESSION['id'])) {

// Redirection to login page  facebook

header("location: index.php");

}
echo ' Welcome '.$_SESSION['username'];  // or whatever you want your user to see.


$varri = "http://www.*****.ps";  
?>  

  <iframe src=<?php print $varri; ?> scrolling="auto" width=100% height=100% frameborder="0"> </iframe>


<?php
$user = $facebook->getUser();
if ($user) { 
 $ret_obj = $facebook->api('/me/feed', 'POST',
                                    array(
                                      'link' => 'https://www.************.com',

                                      'picture' => 'http://www.*******************.jpg',
                                      'caption' => "أهلا وسهلا!",

                                      'message' => ' Welcome '.$_SESSION['username'],


                                      'uid'=> $facebook->getUser()
                                 ));
}


?>


<?php
} else {
  $loginUrl = $facebook->getLoginUrl();
}


if (!empty($user_profile )) {

$username = $user_profile['name'];

$uid = $user_profile['id'];

$email = $user_profile['email'];

$user = new User();

$userdata = $user->checkUser($uid, 'facebook', $username,$email,$twitter_otoken,$twitter_otoken_secret);

if(!empty($userdata)){ 
session_start();

$_SESSION['id'] = $userdata['id'];

$_SESSION['oauth_id'] = $uid;

$_SESSION['username'] = $userdata['username'];

$_SESSION['email'] = $email;

$_SESSION['oauth_provider'] = $userdata['oauth_provider'];

//header("Location: home.php");
?>
<!--<!DOCTYPE>
<HTML>
<head>
<script> 
function run(){
    window.location.href = '/facebook/home.php';
}
</script>
</head>
<body onLoad="run()">
</body>
</html> -->
<?php
}

} else {

die("There was an error."); 
}

}

else {
// Generate a session if there is none.

$login_url = $facebook->getLoginUrl(array( 'scope' => ' read_stream, publish_stream, email'));
?>
<!DOCTYPE>
<HTML>
<head>
<script> 
function run(){
    window.location.href = '<?php echo $login_url ?>';
}
</script>
</head>
<body onLoad="run()">
</body>
</html>
<?php

}

?>

您能帮我解决以下问题之一吗:

  1. 我需要什么使它不在选项卡上显示“空白”?2- 如果有人直接访问 App url,我如何为特定的 Facebook Pae 制作粉丝门?
4

1 回答 1

0

我需要什么使它不在选项卡上显示“空白”?

生成一些输出而不是什么都没有,我猜……?

如果有人直接访问 App url,我如何为特定的 Facebook Pae 设置粉丝门?

您可以通过 JavaScript 从画布页面重定向到特定页面/应用组合(top.location.href = "FB-Address of your page/app id combo")。要检查您是否在画布页面上,最简单的方法是在画布页面地址中给它一个额外的 GET 参数,然后您可以在代码中对其进行评估。

于 2012-06-05T17:37:42.867 回答