当前位置: 首页 > news >正文

济南小程序网站制作桦甸网站开发定制

济南小程序网站制作,桦甸网站开发定制,网页设计实训总结50字,网站从设计到制作下载地址: https://githubfast.com/anerg2046/sns_auth 安装方式建议使用composer进行安装 如果linux执行composer不方便的话,可以在本地新建个文件夹,然后执行上面的composer命令,把代码sdk和composer文件一起上传到项目适当位…

下载地址:

https://githubfast.com/anerg2046/sns_auth

安装方式建议使用composer进行安装

如果linux执行composer不方便的话,可以在本地新建个文件夹,然后执行上面的composer命令,把代码sdk和composer文件一起上传到项目适当位置:然后,

示例代码:

<?php//以thinkCMF框架为例namespace app\home\controller;use cmf\controller\HomeBaseController;use think\facade\Db;use anerg\OAuth2\OAuth;class UserController extends HomebaseController{private function getThirdConfig($name){$site='http://xxxx.com'; //更改为自己站点域名//下面的参数需要根据自己的实际需求替换$line_config=['app_id'=>'login_line_appid','app_secret'=>'login_line_secret','scope'=>'profile'];$facebook_config=['app_id'=>'login_facebook_appid','app_secret'=>'login_facebook_secret','scope'=>'public_profile'];$google_config=['app_id'=>'login_google_appid'.'.apps.googleusercontent.com','app_secret'=>'login_google_secret','scope'=>'https://www.googleapis.com/auth/userinfo.profile'];$twitter_config=['app_id'=>'login_twitter_appid','app_secret'=>'login_twitter_secret'];$config=[];switch ($name) {case 'line':$config=$line_config;break;case 'facebook':$config=$facebook_config;break;case 'google':$config=$google_config;break;case 'twitter':$config=$twitter_config;break;}$config['callback']=$site.'/home/user/'.$name.'_callback';return $config;}/*** Line登录*/public function line(){require_once '/sns_auth/vendor/autoload.php';$name='line';$config=$this->getThirdConfig($name);return redirect(OAuth::$name($config)->getRedirectUrl());}/**Line登陆回调**/public function line_callback(){$code= $_GET['code'] ?? '';if($code!=""){$this->third_callback('line');}else{$this->error('三方回调信息获取失败');}}/*** facebook登录*/public function facebook(){require_once '/sns_auth/vendor/autoload.php';$name='facebook';$config=$this->getThirdConfig($name);return redirect(OAuth::$name($config)->getRedirectUrl());}/*** Facebook登陆回调*/public function facebook_callback(){$code= $_GET['code'] ?? '';if($code!=""){$this->third_callback('facebook');}else{$this->error('三方回调信息获取失败');}}/*** Google登录*/public function google(){require_once '/sns_auth/vendor/autoload.php';$name='google';$config=$this->getThirdConfig($name);return redirect(OAuth::$name($config)->getRedirectUrl());}/*** Google登陆回调*/public function google_callback(){$code= $_GET['code'] ?? '';if($code!=""){$this->third_callback('google');}else{$this->error('三方回调信息获取失败');}}/*** twitter登录*/public function twitter(){require_once '/sns_auth/vendor/autoload.php';$name='twitter';$config=$this->getThirdConfig($name);return redirect(OAuth::$name($config)->getRedirectUrl());}/*** twitter登陆回调*/public function twitter_callback(){$code= $_GET['code'] ?? '';if($code!=""){$this->third_callback('twitter');}else{$this->error('三方回调信息获取失败');}}protected function third_callback($name){require_once '/sns_auth/vendor/autoload.php';$config=$this->getThirdConfig($name);$openinfo = OAuth::$name($config)->userinfo();if(!$openinfo){$this->error('三方信息验证失败');return;}/*$openinfo=['openid'=>'唯一标识','channel'=>'line','nick'=>'line昵称','gender'=>'性别','avatar'=>'line头像'];*/$openid=$openinfo['openid'];$channel=$openinfo['channel'];$nickname=$openinfo['nick'];$avatar=$openinfo['avatar'];$userinfo=$this->loginByThird($channel,$openid,$nickname,$avatar);if($userinfo==1001){$this->assign("jumpUrl",'/');$this->error('该账号已被禁用');return;}if($userinfo==1002){$this->assign("jumpUrl",'/');$this->error('该账号已被注销');return;}if($userinfo==1003){$this->assign("jumpUrl",'/');$this->error('该账号已被禁用');return;}$configpub=getConfigPub();session('uid',$userinfo['id']);session('token',$userinfo['token']);session('user',$userinfo);$href='http://xxxx.com'; //替换为自己站点的域名echo "<meta http-equiv=refresh content='0; url=$href'>";}protected function loginByThird($type,$openid,$nickname,$avatar){//实际业务代码,根据自己项目做修改$info=DB::name('user')->where("openid='{$openid}' and login_type='{$type}' and user_type=2")->find();if(!$info){/* 注册 */$user_pass='abcdefg123456';$user_pass=cmf_password($user_pass); //密码加密,方法请自己实现$user_login=$type.'_'.time().rand(100,999);if(!$nickname){$nickname=$type.'用户-'.substr($openid,-4);}else{$nickname=urldecode($nickname);}if(!$avatar){$avatar='/default.jpg';$avatar_thumb='/default_thumb.jpg';}else{$avatar=urldecode($avatar);$avatar_thumb=$avatar;}$data=array('user_login'    => $user_login,'user_nickname' =>$nickname,'user_pass'     =>$user_pass,'signature'     =>'这家伙很懒,什么都没留下','avatar'        =>$avatar,'avatar_thumb'  =>$avatar_thumb,'last_login_ip' =>get_client_ip(0,true),'create_time'   => time(),'user_status'   => 1,'openid'        => $openid,'login_type'    => $type,"user_type"     =>2,//会员"source"        =>'pc');$uid=DB::name('user')->insertGetId($data);$info['id']=$uid;$info['user_nickname']=$data['user_nickname'];$info['avatar']=$data['avatar'];$info['avatar_thumb']=$data['avatar_thumb'];$info['sex']='2';$info['signature']=$data['signature'];$info['coin']='0';$info['login_type']=$data['login_type'];$info['province']='';$info['city']='';$info['birthday']='';$info['consumption']='0';$info['votestotal']='0';$info['user_status']=1;$info['last_login_time']='';$info['end_bantime']='0';}else{if(!$avatar){$avatar='/default.jpg';$avatar_thumb='/default_thumb.jpg';}else{$avatar=urldecode($avatar);$avatar_thumb=$avatar;}$info['avatar']=$avatar;$info['avatar_thumb']=$avatar_thumb;$data=array('avatar' =>$avatar,'avatar_thumb' =>$avatar_thumb,);}if($info['user_status']=='0'){return 1001;					}if($info['user_status']=='3'){return 1002;					}if($info['user_status']=='1'&& $info['end_bantime']>time()){return 1003;					}$info['isreg']='0';$info['isagent']='0';if($info['last_login_time']=='' ){$info['isreg']='1';$info['isagent']='1';}$info['avatar']=get_upload_path($info['avatar']);$info['avatar_thumb']=get_upload_path($info['avatar_thumb']);return $info;}}

代码中各个配置参数如何获取:

facebook:

Line:

Google:

http://www.yayakq.cn/news/700993/

相关文章:

  • 阿里云搭建安装wordpress教程安徽网络关键词优化
  • 在自己的网站上怎么做淘宝客有哪些做共享充电宝的网站
  • 广州建网站的公司wordpress js 添加图片
  • 郑州做网站锐中国建设部网站监理延续
  • 网站建设动态静态中国城乡住房和建设部网站
  • 服务器做jsp网站教程视频浙江网站建设平台
  • 上海工商网站查询企业信息如何检测网站开发商留有后门
  • 网站建设需要的项目网站推广必备的工具
  • 怎么买速成网站wordpress创建页面失败
  • 优秀网站建设空间沈阳企业自助建站
  • 珠海网站推广排名做家政网站公司简介
  • 网站建设西班牙语自学免费网站建设
  • 北京cms建站模板软件开发属于哪个专业
  • 黄山找人做网站岳阳有哪几家做网站的
  • 龙岩公司网站建设网站网络营销
  • 物流网站毕业设计房屋设计平面图
  • 深度网站建设网页设计什么专业
  • 网站建设可用性的五个标准钓鱼网站怎么制作html
  • 个人怎样注册网站最有效的恶意点击
  • 淘宝客网站能用淘宝图标做标志吗黔西南州住房和城乡建设局网站
  • 个人商城网站备案福建泉州网站建设公司
  • 视差网站国内永久免费的crm
  • 西安网站建设多钱郑州动力无限网站建设
  • 认证空间官方网站网上商城app开发
  • 南宁网站推广v1有什么做兼职的好的网站
  • 聚诚商务做网站多少钱cms怎么搭建网站
  • 建设局网站新闻做网站含备案费么
  • 计算机网站建设教程比较好的网站公司
  • 亚马逊购物网站小红书小程序入口
  • 德州 网站建设网站免费推广计划