1.https://developer.twitter.com/创建应用

放开想用的权限及配置回调地址和网址

2.下载类库

链接:https://pan.baidu.com/s/16xDOUiLEIZuRSNt6Z9afdg 
提取码:aqkf 
复制这段内容后打开百度网盘手机App,操作更方便哦

3.授权链接

public function loginTwitter() { require "../lib/internal/twitteroauth/twitteroauth.php";        $ttConfig = $this->snsaccount->twitterAccount();// Create TwitterOAuth obj instance$twitteroauth = new \TwitterOAuth('api_key', 'api_secret');// Requesting authentication tokens, the parameter is the URL we will be redirected to$redirectUrl = '回调地址';$request_token = $twitteroauth->getRequestToken($redirectUrl);// save to session$_SESSION['oauth_token'] = $request_token['oauth_token'];$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];// no errorif($twitteroauth->http_code==200){// Let's generate the URL and redirect$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);     header('Location: '. $url);} else {// error$this->messageManager->addErrorMessage(__('twitter login fail'));}        }

4.回调方法

public function loginTwitterRedirect(){require "../lib/internal/twitteroauth/twitteroauth.php"; $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');if(!empty($oauth_verifier) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])){// The data is legal. Go ahead// TwitterOAuth Object instance, pay attention to the two newly added parameters$twitteroauth = new \TwitterOAuth('api_key', 'api_secret', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);// access token$access_token = $twitteroauth->getAccessToken($oauth_verifier);           $_SESSION['access_token'] = $access_token;// Get user information$auth_param = array('include_email'=>true);$user_info = $twitteroauth->get('account/verify_credentials',$auth_param);      print_r($user_info); die;             $type = 'twitter';$client_id = $user_info['id'];$client_name = $user_info['screen_name'];            $client_email = $user_info['email'];$this->getCustomerBySns($type,$client_id,$client_name,$client_email);} else {// Incomplete data, go to the previous step$prev_url = $this->_url->getUrl('appcustomer/account/loginsns',['sns'=>'twitter']);header('Location: '.$prev_url);}}

参考:https://blog.51cto.com/dapingguo/469136

PHP对接twitter三方登录-WEB版相关推荐

  1. HttpClient 模拟登录Web版新浪微博

    上篇介绍了如何模拟登录手机版微博,过程还是比较简单的,没有设计到复杂的加密部分. 登录Web版微博的过程还是一样的,只不过这次需要提交的数据多一点. public static Cookie[] ge ...

  2. QQ登录协议php,QQ登录 - web版

    [![](http://static.phpgrace.com/statics/images/downcode.png)](http://www.phpgrace.com/tools/download ...

  3. 对接twitter第三方登录踩的坑

    对接twitter第三方登录踩的坑 1.在twitter开发者项目中创建完应用后在应用的Key and tokens中获取到 appkey 然后把获取到的key放入 hello.init({}) 中的 ...

  4. twitter三方登录的实现

    twitter的三方登录当时研究了不短时间,也算是第一次做三方登录的东西,将oauth标准彻头彻尾的了解了一下,下面是一些当时总结的资料,参考了很多博文 1.去官网注册账号并在开发者网站创建项目 ht ...

  5. JAVA Spring Security对接QQ快速登录(web应用)

    阅读此文需要对Security有大概的了解,了解其运行流程 security对接QQ互联jssdk快速登录 前端使用的是vue.js 1.首先在QQ互联申请一个应用,得到appid和设置好回调地址 2 ...

  6. HttpClient 模拟登录手机版新浪微博

    手机版微博单点登录的URL为:http://3g.sina.com.cn/prog/wapsite/sso/login.php 我们先来看一下这个网页源代码: <html><head ...

  7. 【大学生软件测试基础】web版微信登录测试 - 正交表

    微信是一款手机App软件,但它也有web版微信可以登录,如果要测试微信web页面运行环境,需要考虑多种因素.在众多的因素中,我们可以选出几个影响比较大的因素,如服务器.操作系统,插件和浏览器.对于选取 ...

  8. Android接入三方登录——QQ、微信、Facebook、Twitter

    Android接入三方登录--QQ.微信.Facebook.Twitter 避坑指南 facebook错误1: facebook错误2: QQ 微信 Facebook Twitter 补充: 避坑指南 ...

  9. twitter授权登录 php,PHP版实现Twitter第三方登录的成功案例

    QQ.微信.Fackbook等第三方登录使用OAuth2.0,随便找一些文档跟着做很快实现,没什么难度.等轮到Twitter时候,如果你也这样想,后面它就会证明你是错的! Twitter在当前时间(2 ...

最新文章

  1. 介绍java -cp java -jar的区别
  2. 一天一个设计模式(3)——单例模式
  3. 封装进程内存相关操作函数
  4. 微信企业号:shell定时发送图片 到 指定人
  5. ​【Python入门】Python数学math模块55个函数详解
  6. python多个分隔符分割字符串_Python中带有多个分隔符的拆分字符串
  7. cpu占用高 mongo_排查MongoDB CPU使用率高的问题
  8. C++中数组定义及初始化
  9. qt 多重继承_C++多继承(多重继承)详解
  10. SpringBoot:java.lang.NullPointerException
  11. java执行复杂linux,解决java使用Runtime.exec执行linux复杂命令不成功问题
  12. Qt学习-------常用控件
  13. java命名不规范会怎样_java命名规范:注重细节
  14. MagicDraw-包图
  15. 桌面cpu与服务器cpu天梯,秒懂台式电脑CPU性能 桌面CPU天梯图2017年9月最新版
  16. uniapp引入高德地图sdk经纬度解析诚地址名称
  17. Visual Studio快速配置增加文件版权声明
  18. 北京大学计算机学硕考研分数线,2020北京大学研究生分数线汇总(含2016-2020历年复试)...
  19. 微博怎么批量取消所有的关注
  20. 静态页面笔记包括 html和css

热门文章

  1. [ git ] git托管代码1
  2. 提示:Run-time error ‘339’:Cmponent 'MSCOMCTL.OCX'or one of its dependent..........的时候该怎么办?
  3. 治五气,艺五种,抚万民,度四方
  4. 为什么C语言要有头文件(补充)
  5. python 白噪声检验-利用python实现平稳时间序列的建模方式
  6. 字符串类型的数字的加减乘除运算
  7. 在centos中注册gitlab runner
  8. 手机屏幕测试html5,一加手机5屏幕测试:色彩素质优秀,唯独分辨率是美中不足...
  9. Jira实战 | 界面管理策略
  10. iPhone开发部分总结