dongyu1918 2016-02-13 01:27
浏览 65
已采纳

Jquery自动单击超链接

Hii Everyone, Here is my code for facebook Signin.i got this example from http://www.codexworld.com/login-with-facebook-using-php/. here is my index page code

PHP code

<?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>

Here i use a href to show facebook login.after te click of href it will redirecting to facebook login instead automatically want to click and it will redirect the page.Is there any possible way to do that.If anyone know the solution for the problem please help me!!

展开全部

  • 写回答

2条回答 默认 最新

  • douqi3913 2016-02-13 01:41
    关注

    Why not do this with header location? Here´s how that works: PHP header(Location: ...): Force URL change in address bar

    For example:

    $loginUrl = $facebook->getLoginUrl(array('redirect_uri' => $homeurl, 'scope' => $fbPermissions));
    header("Location: " . $loginUrl);
    

    Official docs: http://php.net/manual/function.header.php

    No need for using an $output variable, or for creating a login page (if you want to auto-redirect anyway). Just redirect the user if he is not logged in yet. No need to do something shady like "auto-clicking the login button". It´s not a solution, it´s a bad workaround. Although, it would be a lot better if you would let the user click it. Redirecting to the login page without a proper intro page, where he can see what the App is about, is not a good idea.

    Even better: Use the JavaScript SDK for login: http://www.devils-heaven.com/facebook-javascript-sdk-login/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥20 谁刷目标页面的uv记录器上数据,数据只记录跳转的数值
  • ¥30 数据库软件的安装方法
  • ¥15 一道以太网数据传输题
  • ¥15 python 下载群辉文件
  • ¥50 代码还没怎么运行但是需要代码功能调用数据
  • ¥15 vue请求不到数据,返回状态200,数据为html
  • ¥15 用白鹭引擎开发棋牌游戏的前端为什么这么难找
  • ¥35 哪位专业人士知道这是什么原件吗?哪里可以买到?
  • ¥15 关于#c##的问题:treenode反序列化后获取不到上一节点和下一节点,Fullpath和Handle报错
  • ¥15 一部手机能否同时用不同的app进入不同的直播间?
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部