2012-06-05 29 views
0

我在Facebook應用程序中遇到問題。 當任何一個人進入應用程序的網址,例如,我想打個扇形門。 apps.facebook.com/zoomcompetition/Facebook上的粉絲門應用程序URL + Facebook標籤顯示空白

我無法在選項卡上顯示它,因爲它顯示爲空白。 ,但它適用於應用程序的URL,所以我想添加應用程序指定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的粉絲門?

回答

0

我需要什麼讓它不在屏幕上顯示「空白」?

生成一些輸出,而不是什麼,我猜... ...?

如果有人直接轉到應用程序URL,我該如何爲特定的Facebook Pae製作粉絲門?

您可以通過JavaScript將頁面重定向到特定頁面/應用程序組合(top.location.href =「FB頁面/應用程序ID組合的地址」)。爲了檢查您是否在畫布頁面上,最簡單的方法是在畫布頁面地址中給它一個額外的GET參數,然後您可以在代碼中評估它。

+0

感謝您的幫助,但我可以在哪裏添加輸出代碼以顯示在選項卡上?我添加了以下代碼以顯示在選項卡上(也可以在上面的完整代碼中找到它),但它顯示bank: 'echo'Welcome'。$ _ SESSION ['username']; //或者你想讓用戶看到的任何東西。 $ varri =「http://www.*****.ps」; ?> ' 我在哪裏可以在我的代碼中添加重定向代碼? – Ahmad

+0

:)............. – Ahmad

相關問題