php 微信擷取使用者資訊全碼

來源:互聯網
上載者:User
這篇文章介紹的內容是關於php 擷取使用者資訊全碼,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下

因為項目需要,我也是一個新手,所以用了兩天把支付,分享,還有擷取使用者資訊做完了,作為一個新手,在網上找代碼真心費力!所以為了,讓更多的新手一看就會,不走彎路,在此特地寫張這篇文章!好了,廢話不多說直接上代碼和方法!我的qq1414970267,不會的直接問我!

config.php 代碼

 <?php session_start(); $appid = 'wxc0edcad16ff403cb'; $secret = '3d3b62ae770eff710eaa9d82722639cd';?>index.php<?phpinclude_once 'config.php';$redirect_uri = "http://www.127ck.com/index1/openid.php";$redirect_uri = urlencode($redirect_uri);$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . $redirect_uri . "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";header('Location: ' . $url . '');?>openid.php<?phpinclude_once 'config.php';$code = $_GET['code'];function get_curl($url) {    $ch = curl_init();    curl_setopt($ch, CURLOPT_POST, 1);    curl_setopt($ch, CURLOPT_HEADER, 0);    curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    $result = curl_exec($ch);    $rs = $result ? json_decode($result, true) : "";     return $rs; }$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret . "&code=" . $code . "&grant_type=authorization_code";$rs = get_curl($url);$openid = $rs['openid'];$access_token = $rs['access_token'];$url_userinfo = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$access_token."&openid=".$openid."&lang=zh_CN";$rs_userinfo = get_curl($url_userinfo);var_dump($rs_userinfo);?>


這就是擷取資訊的全部代碼,代碼親測,絕對可用!不懂可用問我!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.