Okay so I've setup an app which works fine but there's one problem when people add tab to their pages they went to page which show "开发者_开发百科true" it means page is added successful but i want to redirect them to their page or any other link after page tab added successfully.
<?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 }
?>
How can i use redirect to this page which is not mine graph.facebook.com/255826047791900/…***&method=post*
Try this
echo("<script> top.location.href='" . $x . "'</script>");
Why don't you use 'header'?
<?php
header('Location: '.$url);
?>
精彩评论