添加页面选项卡后重定向到另一个链接

时间:2011-10-13 07:23:44

标签: php facebook

好吧所以我设置了一个可以正常使用的应用程序,但是当人们将标签添加到他们的页面时他们转到页面显示“真实”这意味着页面添加成功但我想将它们重定向到他们的页面或页面选项卡成功添加后的任何其他链接。

<?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 / ... * ** &amp; method = post *

2 个答案:

答案 0 :(得分:1)

试试这个

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

答案 1 :(得分:0)

为什么不使用'标题'?

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