我想将我的网站与facebook联系起来。所以我试图制作一个用户登录facebook的按钮。
我想要做的是:将我需要创建帐户的用户数据从我的index.php传递给test.php(因为这是一个测试,之后我会调整它)... 问题是我无法重定向到test.php ... 我可以用表格和按钮做到这一点,但我想在没有任何按钮的情况下做到这一点......
<!-- ---------------------------------------------------------------------------------------
IdiotMinds - http://idiotminds.com
-----------------------------------------------------------------------------------------
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login with Facebook</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/oauthpopup.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#facebook').click(function(e){
$.oauthpopup({
path: 'login.php',
width:600,
height:300,
callback: function(){
window.location.reload();
}
});
e.preventDefault();
});
});
</script>
</head>
<body>
<?php
session_start();
if(!isset($_SESSION['User']) && empty($_SESSION['User'])) { ?>
<img src="images/facebook.png" id="facebook" style="cursor:pointer;float:left;" />
<?php } else { ?>
<form action="test.php" method="post">
<INPUT TYPE = "hidden" name="name" VALUE =<?php echo $_SESSION['User']['first_name'] ?>>
<INPUT TYPE = "hidden" name="lname" VALUE =<?php echo $_SESSION['User']['last_name'] ?>>
<INPUT TYPE = "hidden" name="email" VALUE =<?php echo $_SESSION['User']['email'] ?>>
<INPUT TYPE = "hidden" name="location" VALUE =<?php echo $_SESSION['User']['location']['name'] ?>>
<input type="submit" name="submit"/> /* without this one please */
</form>
<?php
header("Location:test.php?name&lname");
/*
echo '<img src="https://graph.facebook.com/'. $_SESSION['User']['id'] .'/picture" width="30" height="30"/><div>'.$_SESSION['User']['first_name'].'</div><div>'.$_SESSION['User']['last_name'].'</div><div>'.$_SESSION['User']['email'].'</div><div>'.$_SESSION['User']['location']['name'].'</div>';
echo '<a href="'.$_SESSION['logout'].'">Logout</a>';
*/
}
?>
</body>
</html>