2011-10-13 111 views
2

好吧,我已经设置了一个可以正常工作的应用程序,但有一个问题,当人们将标签添加到他们的页面时,他们去了显示“true”的页面,这意味着页面添加成功,但我希望在页面标签添加成功后将它们重定向到他们的页面或任何其他链接。添加页面标签后重定向到另一个链接

<?php 
session_start(); 
$facebook=$_SESSION['facebook']; 
include("facebook/src/facebook.php"); 
$facebook=new Facebook(array(
     'appId' => '197786760292550', 
     'secret' => 'e284332964b213066d3b247e1eb4b4a0', 
    )); 
    $user = $facebook->getUser(); 
    $access_token = $facebook->getAccessToken(); 
if ($user) { 
     try { 
     // Proceed knowing you have a logged in user who's authenticated. 
     $user_profile = $facebook->api('/me'); 
     } catch (FacebookApiException $e) { 
     error_log($e); 
     $user = null; 
     } 
    } 


//Login or logout url will be needed depending on current user state. 

    if ($user) { 

    if(isset($_POST['page'])) 
    { 
    $page=$_POST['page']; 
    $explodepage=explode("with",$page); 
    $acctoken=$explodepage[1]; 
    $pgid=$explodepage[0]; 
    $url="https://graph.facebook.com/".$pgid."/tabs?app_id=197786760292550&access_token=".$acctoken."&method=post"; 
    ?> 
    <script> 
window.top.location="<?php echo $url?>"; 
</script> 
    <?php } 
    $url="https://graph.facebook.com/".$user."/accounts?access_token=".$access_token; 
    $ch = curl_init($url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: graph.facebook.com')); 
$output = curl_exec($ch); 
curl_close($ch); 
$input=json_decode($output); 
$data=$input->data; 
$count=count($data)-1; 
?> <form action="" method="post"> 
<?php for($x=1; $x<=$count; $x++) 
{ 
    $pdata[$x]=$data[$x]; 
    $pname[$x]=$pdata[$x]->name; 
    $ptoken[$x]=$pdata[$x]->access_token; 
    $pid[$x]=$pdata[$x]->id; ?> 
    <img src="https://graph.facebook.com/<?php echo $pid[$x]; ?>/picture"/> 
    <?php echo $pname[$x]."<input type='radio' name='page' value='".$pid[$x]."with".$ptoken[$x]."' /><br>"; 
} echo "<input type='submit' name='submit'></form>"; } else { 
    $app=197786760292550; 
$appsecret="e284332964b213066d3b247e1eb4b4a0"; 
$url="http://www.facebook.com/dialog/oauth?"; 
$redirect="http://luutaa.co.in/fb_close/access_token.php"; 
$scope="manage_pages,publish_stream"; 
$x=$url."client_id=".$app."&redirect_uri=".$redirect."&scope=".$scope; 
?> 
<script> 
window.top.location = "<?php echo $x?>"; 
</script> 
    <?php } 
?> 

如何使用重定向到该页面不属于我graph.facebook.com/255826047791900/... * ** &方法=张贴 *

回答

1

试试这个

echo("<script> top.location.href='" . $x . "'</script>"); 
+0

它仍然显示该页面,如果你知道任何其他编码方式不会产生像这样的问题,然后告诉我,我也会尝试。 –

+0

你试过 <?php echo(“”); ?> – Amila

+0

是的,但它没有帮助 –

0

为什么不你使用'标题'?

<?php 
header('Location: '.$url); 
?> 
+0

如何使用页眉这一页是不是我https://graph.facebook.com/255826047791900/tabs?app_id=197786760292550&access_token=***** ***&method = post –

相关问题