QQ登陆绑定代码

//本代码并非完美,也许存在不良之处,高手请多指点,请勿吐槽!

 //qq登陆
 public function qq_login(){
    vendor('Connect.qqConnectAPI');
    $qc = new QC();
    $qc->qq_login();
 }
 //qq验证登陆
 public function qq_callback(){
    vendor('Connect.qqConnectAPI');
    $qc = new QC();
    $qc->qq_callback();
    $qc->get_openid();
    $this->success("QQ登陆成功",U('Login/qq_user'));
 }
 //qq取资料
 public function qq_user(){
    vendor('Connect.qqConnectAPI');
    $qc = new QC();
    $arr = $qc->get_user_info();
    //判断是否绑定
    $Q=M('QQ绑定数据库');
    $where['openid']=$_SESSION['QC_userData']['openid'];
    $isqq=$Q->where($where)->find();
    if($isqq){
                //如果已绑定某用户,则用uid取用户名直接session到此用户
    }else{
                //如果未绑定则跳转到完善用户信息
        session('head',$arr['figureurl_2']);
        session('nick',$arr['nickname']);
        $this->success("请完善用户信息",U('Login/reg_qq'));
    }
 }
 //qq注册完善信息
 public function reg_qq(){
        if(IS_POST){
            $user=$this->_post('uname');//用户名
            $pwd=$this->_post('pwd');//密码
            $repwd=$this->_post('repwd');//重复密码
            $ip=get_client_ip();
            
                $User=M("User");
            
                //判断用户是否存在
                $whereus['user']=$user;
            if($User->where($whereus)->find()){
                $this->error('对不起,此用户名已存在,请更换!');
            }
                        //这是用户信息,根据你自己的数据库定
            $data['user']=$user;
            $data['pwd']=md5($pwd);
            $data['nick']=session('nick');
            $data['head']=session('head');
            $data['reg_time']=time();
            $data['login_time']=time();
            $data['reg_ip']=$ip;
            $data['dow_score']=20;
            $data['login_ip']=$ip;    
                $isus=$User->add($data);
            
            if($isus){
               //绑定qq
               $Q=M("Qq_user");
               $Qdata['access_token']=$_SESSION['QC_userData']['access_token'];
               $Qdata['openid']=$_SESSION['QC_userData']['openid'];
               $Qdata['time']=time();
               $Qdata['uid']=$isus;
                   $Q->add($Tdata);
                    $this->success('注册成功,请使用QQ登陆或账号密码登陆!',U('Index/index'));
                }else{
                    $this->error('注册成功,但QQ绑定失败,请登陆后再次绑定!');
                }
        }else{
            $this->display();
        }
        
    }

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用Java语言和Swing GUI库来实现模拟QQ登录的代码示例: ```java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class QQLogin extends JFrame implements ActionListener { private JLabel lblAccount, lblPassword; private JTextField txtAccount; private JPasswordField txtPassword; private JButton btnLogin, btnCancel; public QQLogin() { super("QQ Login"); // 创建组件 lblAccount = new JLabel("Account:"); lblPassword = new JLabel("Password:"); txtAccount = new JTextField(20); txtPassword = new JPasswordField(20); btnLogin = new JButton("Login"); btnCancel = new JButton("Cancel"); // 设置布局管理器 setLayout(new GridLayout(3, 2)); // 添加组件 add(lblAccount); add(txtAccount); add(lblPassword); add(txtPassword); add(btnLogin); add(btnCancel); // 注册事件监听器 btnLogin.addActionListener(this); btnCancel.addActionListener(this); // 设置窗口属性 setSize(300, 150); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); setVisible(true); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btnLogin) { // 获取输入的账号和密码 String account = txtAccount.getText(); String password = new String(txtPassword.getPassword()); // 模拟登录操作 if (account.equals("admin") && password.equals("123456")) { JOptionPane.showMessageDialog(this, "Login succeed!"); } else { JOptionPane.showMessageDialog(this, "Login failed!"); } } else if (e.getSource() == btnCancel) { System.exit(0); } } public static void main(String[] args) { new QQLogin(); } } ``` 运行该程序,将显示一个简单的登录窗口,用户可以在该窗口中输入QQ账号和密码,并通过点击“Login”按钮来模拟登录操作。如果输入的账号和密码与预设的值匹配,则会显示“Login succeed!”的提示框,否则会显示“Login failed!”的提示框。用户也可以通过点击“Cancel”按钮来退出程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值