【发布时间】:2016-05-24 12:34:24
【问题描述】:
大家好, 这是我的 facebook Signin 代码。我从 http://www.codexworld.com/login-with-facebook-using-php/ 获得了这个示例。这是我的索引页代码
PHP 代码
<?php
include_once("config.php");
include_once("includes/functions.php");
//destroy facebook session if user clicks reset
if(!$fbuser){
$fbuser = null;
$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
$output = '<a class="myLink" href="'.$loginUrl.'">Click Here To Proceed</a>';
}else{
$user_profile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,birthday,picture');
$user = new Users();
$user_data = $user->checkUser('facebook',$user_profile['id'],$user_profile['first_name'],$user_profile['last_name'],$user_profile['email'],$user_profile['gender'],$user_profile['birthday'],$user_profile['picture']['data']['url']);
if(!empty($user_data)){
$output = 'Thanks For Register With Spark.You Should Receive Confirmation Mail Shortly';
}else{
$output = '<h3 style="color:red">Some problem occurred, please try again.</h3>';
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Spark Login with Facebook</title>
<style type="text/css">
h1{font-family:Arial, Helvetica, sans-serif;color:#999999;}
</style>
</head>
<body>
<div>
<?php echo $output; ?>
</div>
</body>
</html>
在这里我使用href来显示facebook登录。点击href后它将重定向到facebook登录而不是自动想要点击并重定向页面。有没有可能的方法来做到这一点。如果有人知道解决方案有什么问题请帮帮我!!
【问题讨论】:
-
即使您不打算按照建议进行服务器端重定向,也无需“单击带有 jQuery 的链接”,而是将 URL 简单分配给 @987654323 @ 会达到同样的效果。
标签: javascript php jquery facebook