您的位置 首页 php

PHP模拟QQ网页版授权登陆

本篇文章小编将带大家一起学习一下如何用PHP模拟QQ网页版授权登录,附上代码,具有一定的参考价值,大家一起来学习一下吧!

第一步:

首先登陆QQ互联首页https://connect.qq.com/进行个人/企业认证。大概审核时间在一周左右。

PHP模拟QQ网页版授权登陆

认证通过之后创建应用:

PHP模拟QQ网页版授权登陆

这里主要用到应用的APP ID APP Key 这两个参数。

还要填写回调地址 就是请求qq接口获取code参数回调给你的地址

PHP模拟QQ网页版授权登陆

第二步:

准备工作做完之后就可以进行接入qq授权 这里直接上demo代码:

<?php/** * Project:QQ授权登陆 * User: luokakale * Date: 2019/1/25 * Time: 14:22 *///应用的APPID$app_id = "";//应用的APPKEY$app_secret = "";//【成功授权】后的回调地址,即此地址在腾讯的信息中有储存$my_url = "http://XXXXXXX/login.php";/* * No1:获取Authorization Code */session_start();if(empty($code)){    //state参数用于防止CSRF攻击,成功授权后回调时会原样带回    $_SESSION['qq_state'] = md5(uniqid(rand(), TRUE));    //拼接URL    $dialog_url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state=" . $_SESSION['qq_state'];    echo("<script> top.location.href='" . $dialog_url . "'</script>");}//获取qq回调时返回的code参数$code = $_REQUEST["code"];//存放Authorization Code/* * NO.2 通过Authorization Code获取Access Token */if($_REQUEST['state'] == $_SESSION['qq_state'] ) {    //拼接URL获取access_token    $token_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&"."client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)."&client_secret=" . $app_secret . "&code=" . $code;    $response = file_get_contents($token_url);}/* * NO.3:获取用户openID *///把传回来的数据参数变量化$params = array();parse_str($response, $params);$graph_url = "https://graph.qq.com/oauth2.0/me?access_token=".$params['access_token'];$str = file_get_contents($graph_url);$user = json_decode($str);//存放返回的数据 client_id ,openid/* * NO.4:使用access_token来获取所接受的用户信息。 */$user_data_url = "https://graph.qq.com/user/get_user_info?access_token={$params['access_token']}&oauth_consumer_key={$app_id}&openid={$user->openid}&format=json";$user_data = file_get_contents($user_data_url);//此为获取到的user信息$user_data = json_decode($user_data, true);

拿到用户信息后可以进行一系列的逻辑判断。就这么简单。

想成为行业大牛,还得勤加学习,学习更多PHP教程,请关注PHP中文网的PHP视频教程!

以上就是PHP模拟QQ网页版授权登陆的详细内容,更多请关注求知技术网其它相关文章!

文章来源:智云一二三科技

文章标题:PHP模拟QQ网页版授权登陆

文章地址:https://www.zhihuclub.com/5579.shtml

关于作者: 智云科技

热门文章

评论已关闭

41条评论

  1. Stimulating blood pressure for our website, male enhancement exercises We offer cutting-edge treatments, including Tomo-Therapy image guided radiation therapy, minimally invasive surgical techniques, access to the most modern medical therapies, and behavioral and observational therapy in lieu of surgery or medication when appropriate and supported by controlled studies

  2. Plant based foods like vegetables, fruits, nuts, beans, and tofu are all popular choices in the vegan meal plan

  3. The bacterium responsible for the infection is commonly Borrelia burgdorferii. In the noninferiority design, we used one- sided testing with an alpha significance level of 0.

  4. Accepted 28 November 2020 And him begging his too cute for him wife to get him off the crazy thing

  5. Pamela Duff, RN, CSNC Watson et al Curcumin induced apoptosis in ovarian carcinoma cells is p53 independent and involves p38 mitogen activated protein kinase activation and downregulation of Bcl 2 and survivin expression and Akt signaling

  6. The present disclosure relates to certain heteroaryl compounds and pharmaceutically acceptable salts thereof that inhibit the G12C mutant of Kirsten rat sarcoma KRAS protein and are expected to have utility as therapeutic agents, for example, for treatment of cancer

  7. In addition, we showed that the AAV mediated ectopic expression of the endogenous transcription factor TF KLF15 similarly generate robust RHO silencing The primary outcome of interest was the cost per quality adjusted life year QALY gained, associated with AIs versus tamoxifen or placebo, in the case of the extended adjuvant setting

  8. One forage lead to another and it became addicting Expression of Nrf2 and SQSTM1 in clinical endometrial tissues

  9. Monitor Closely 1 nafcillin will decrease the level or effect of osilodrostat by affecting hepatic intestinal enzyme CYP3A4 metabolism Citation Chen B, Dai D, Tang H, Chen X, Ai X, Huang X, Wei W, Xie X

  10. Prior to these, she held positions at various well known companies, including Vanda Pharmaceuticals Inc

  11. Did you get anymore info on this topic Vascular smooth muscle is controlled by circulating vasoactive agents or by autonomic nerves

  12. From these chimeras, we were able to obtain progeny carrying the Tg iSuRe Cre allele and without MbTomato 2A Int Cre expression or recombination of th e Rbpj floxed allele Fig It can also affect a woman s self esteem or may have psychological impact as a result of breast cancer

  13. Is lisinopril bad for you long term 34, 35 There are notable variations among agents within different drug classes, which are summarized in Table 1

  14. The radioactivity concentration in pigmented skin declined over time and dropped to BLQ by 168 h post- dose

  15. Technique begin of the study centrifugation and swim up method, no wash; later on Percoll gradient method and wash 904 Guayaba limГіn x 144 tabs

  16. Each symbol represents an independent section; two to three independent sections animal were used in the ranking

  17. LainГ© AL, Clavreul A, Rousseau A, TГ©taud C, Vessieres A, Garcion E, Jaouen G, Aubert L, Guilbert M, Benoit JP, Toillon RA, Passirani C Your doctor will figure out what s going on and prescribe the right medicine for you

  18. Among other things, we will collect data about the type of computer you use, your Internet connection, your IP address, your operating system, and your browser type

  19. Prevalence and treatment of dry eye in a managed care population Last year Health Rising brought you a startling development a small company called Cortene was going to test its drug in ME CFS

  20. MIT Press, 1989 Các phân tích cũng đến thấy rằng, đau tim thường xuất hiện tối đa vào những phút giây trông đợi khoảnh khắc làm bàn

  21. These sows subsequently gave birth to 525 piglets; 265 from the placebo sow group and 260 from the homeopathic E

  22. Quality content is the important to invite the people to pay a quick visit the site, that’s what this web page is providing.

网站地图