Home WeChat Applet WeChat Development WeChat authorized login and obtain user information interface

WeChat authorized login and obtain user information interface

Mar 01, 2017 am 09:19 AM
WeChat development

I am currently developing a WeChat interface, so I will summarize the development process of this interface by authorizing login with WeChat and obtaining user information.

1. First, your WeChat official account must obtain the corresponding AppID and AppSecret. After applying for WeChat login and passing the review, you can start the access process.

2. Authorization process

1. Process description

(1). The third party initiates a WeChat authorization login request, and after the WeChat user allows authorization of the third-party application, WeChat will launch the application or redirect to a third-party website, and bring the authorization temporary ticket code parameter;

(2). Add AppID and AppSecret, etc. through the code parameter, through the API In exchange for access_token;

(3). Make interface calls through access_token to obtain the user's basic data resources or help the user implement basic operations.

2. Obtain the access_token sequence diagram:

WeChat authorized login and obtain user information interface

3. Development (I use the CI framework, but in fact it is the same with any framework, MVC The mode will do)

1. Request CODE

weixin.php

<?php
    class weixinController extends CI_Controller {
        public $userInfo;
        public $wxId;


        public function __construct(){
            parent::__construct();

            //只要用户一访问此模块,就登录授权,获取用户信息
            $this->userInfo = $this->getWxUserInfo();
        }
    

        /**
         * 确保当前用户是在微信中打开,并且获取用户信息
         *
         * @param string $url 获取到微信授权临时票据(code)回调页面的URL
         */
        private function getWxUserInfo($url = &#39;&#39;) {
            //微信标记(自己创建的)
            $wxSign = $this->input->cookie(&#39;wxSign&#39;);
            //先看看本地cookie里是否存在微信唯一标记,
            //假如存在,可以通过$wxSign到redis里取出微信个人信息(因为在第一次取到微信个人信息,我会将其保存一份到redis服务器里缓存着)
            if (!empty($wxSign)) {
                //如果存在,则从Redis里取出缓存了的数据
                $userInfo = $this->model->redisCache->getData("weixin:sign_{$wxSign}");
                if (!empty($userInfo)) {
                    //获取用户的openid
                    $this->wxId = $userInfo[&#39;openid&#39;];
                    //将其存在cookie里
                    $this->input->set_cookie(&#39;wxId&#39;, $this->wxId, 60*60*24*7);
                    return $userInfo;
                }
            }

            //获取授权临时票据(code)
            $code = $_GET[&#39;code&#39;];
            if (empty($code)) {
                if (empty($url)) {
                    $url = rtirm($_SERVER[&#39;QUERY_STRING&#39;], &#39;/&#39;);
                    //到WxModel.php里获取到微信授权请求URL,然后redirect请求url
                    redirect($this->model->wx->getOAuthUrl(baseUrl($url)));
                }
            }


        }

    }
?>
Copy after login

Get the Controller code of code

Wxmodel.php

<?php
    class WxModel extends ModelBase{
        public $appId;
        public $appSecret;
        public $token;

        public function __construct() {
            parent::__construct();

            //审核通过的移动应用所给的AppID和AppSecret
            $this->appId = &#39;wx0000000000000000&#39;;
            $this->appSecret = &#39;00000000000000000000000000000&#39;;
            $this->token = &#39;00000000&#39;;
        }

        /**
         * 获取微信授权url
         * @param string 授权后跳转的URL
         * @param bool 是否只获取openid,true时,不会弹出授权页面,但只能获取用户的openid,而false时,弹出授权页面,可以通过openid获取用户信息
         *   
        */
       public function getOAuthUrl($redirectUrl, $openIdOnly, $state = &#39;&#39;) {
        $redirectUrl = urlencode($redirectUrl);
        $scope = $openIdOnly ? &#39;snsapi_base&#39; : &#39;snsapi_userinfo&#39;;
        $oAuthUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$this->appId}&redirect_uri={$redirectUrl}&response_type=code&scope=$scope&state=$state";
        return $oAuthUrl;
       }

获取code的Model代码
Copy after login

Get the Model code of code

Attached here are the request parameter description and return value description

Request parameter description:

WeChat authorized login and obtain user information interface

Response return value description:

WeChat authorized login and obtain user information interface

When the request is successful , will redirect to the value of redirect_uri in the request parameter. In fact, it will return to the line $this->userInfo = $this->getWxUserInfo(); in weixin.php, and then enter getWxUserInfo() again Method, at this time the

            //获取授权临时票据(code)
            $code = $_GET[&#39;code&#39;];
Copy after login

line can also get the value of the code. Then proceed to the second step.

2. Get access_token through code

weixin.php

userInfo = $this->getWxUserInfo();
        }
    

        /**
         * 确保当前用户是在微信中打开,并且获取用户信息
         *
         * @param string $url 获取到微信授权临时票据(code)回调页面的URL
         */
        private function getWxUserInfo($url = '') {
            //微信标记(自己创建的)
            $wxSign = $this->input->cookie('wxSign');
            //先看看本地cookie里是否存在微信唯一标记,
            //假如存在,可以通过$wxSign到redis里取出微信个人信息(因为在第一次取到微信个人信息,我会将其保存一份到redis服务器里缓存着)
            if (!empty($wxSign)) {
                //如果存在,则从Redis里取出缓存了的数据
                $userInfo = $this->model->redisCache->getData("weixin:sign_{$wxSign}");
                if (!empty($userInfo)) {
                    //获取用户的openid
                    $this->wxId = $userInfo['openid'];
                    //将其存在cookie里
                    $this->input->set_cookie('wxId', $this->wxId, 60*60*24*7);
                    return $userInfo;
                }
            }

            //获取授权临时票据(code)
            $code = $_GET[&#39;code&#39;];
            if (empty($code)) {
                if (empty($url)) {
                    $url = rtirm($_SERVER['QUERY_STRING'], '/');
                    //到WxModel.php里获取到微信授权请求URL,然后redirect请求url
                    redirect($this->model->wx->getOAuthUrl(baseUrl($url)));
                }
            }
            /***************这里开始第二步:通过code获取access_token****************/
            $result = $this->model->wx->getOauthAccessToken($code);

            //如果发生错误
            if (isset($result['errcode'])) {
                return array('msg'=>'授权失败,请联系客服','result'=>$result);
            }

            //到这一步就说明已经取到了access_token
            $this->wxId = $result['openid'];
            $accessToken = $result['access_token'];
            $openId = $result['openid'];

            //将openid和accesstoken存入cookie中
            $this->input->set_cookie('wx_id', $this->wxId, 60*60*24*7);
            $this->input->set_cookie('access_token', $accessToken);

获取access_token的控制器代码
Copy after login

Get the controller code of access_token

WxModel.php

<?php
    class WxModel extends ModelBase{
        public $appId;
        public $appSecret;
        public $token;

        public function __construct() {
            parent::__construct();

            //审核通过的移动应用所给的AppID和AppSecret
            $this->appId = &#39;wx0000000000000000&#39;;
            $this->appSecret = &#39;00000000000000000000000000000&#39;;
            $this->token = &#39;00000000&#39;;
        }


        /**
         * 获取微信授权url
         * @param string 授权后跳转的URL
         * @param bool 是否只获取openid,true时,不会弹出授权页面,但只能获取用户的openid,而false时,弹出授权页面,可以通过openid获取用户信息
         *   
        */
        public function getOAuthUrl($redirectUrl, $openIdOnly, $state = &#39;&#39;) {
            $redirectUrl = urlencode($redirectUrl);
            $scope = $openIdOnly ? &#39;snsapi_base&#39; : &#39;snsapi_userinfo&#39;;
            $oAuthUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$this->appId}&redirect_uri={$redirectUrl}&response_type=code&scope=$scope&state=$state#wechat_redirect";
            return $oAuthUrl;
        }


        /**
        * 获取access_token
        */
        public function getoAuthAccessToken($code) {
            return json_decode(file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid={$this->AppId}&secret={$this->AppSecret}&code={$authCode}&grant_type=authorization_code",true);
        }

获取access_token的Model代码
Copy after login

Get the Model code of access_token

Attached here is the parameter description

Request parameter description:

WeChat authorized login and obtain user information interface

Response return value description:

WeChat authorized login and obtain user information interface

When an error is returned, it looks like this:

WeChat authorized login and obtain user information interface

3. Call the interface through access_token (obtain user information)
After obtaining the access_token, make the interface call with the following prerequisites:

  (1) access_tokec is valid and has not timed out;

  (2) The WeChat user has authorized the corresponding interface scope (scope) of the third-party application account.

 

The following is the code to obtain user information

weixin.php

userInfo = $this->getWxUserInfo();
        }
    

        /**
         * 确保当前用户是在微信中打开,并且获取用户信息
         *
         * @param string $url 获取到微信授权临时票据(code)回调页面的URL
         */
        private function getWxUserInfo($url = '') {
            //微信标记(自己创建的)
            $wxSign = $this->input->cookie('wxSign');
            //先看看本地cookie里是否存在微信唯一标记,
            //假如存在,可以通过$wxSign到redis里取出微信个人信息(因为在第一次取到微信个人信息,我会将其保存一份到redis服务器里缓存着)
            if (!empty($wxSign)) {
                //如果存在,则从Redis里取出缓存了的数据
                $userInfo = $this->model->redisCache->getData("weixin:sign_{$wxSign}");
                if (!empty($userInfo)) {
                    //获取用户的openid
                    $this->wxId = $userInfo['openid'];
                    //将其存在cookie里
                    $this->input->set_cookie('wxId', $this->wxId, 60*60*24*7);
                    return $userInfo;
                }
            }

            //获取授权临时票据(code)
            $code = $_GET[&#39;code&#39;];
            if (empty($code)) {
                if (empty($url)) {
                    $url = rtirm($_SERVER['QUERY_STRING'], '/');
                    //到WxModel.php里获取到微信授权请求URL,然后redirect请求url
                    redirect($this->model->wx->getOAuthUrl(baseUrl($url)));
                }
            }
            /***************这里开始第二步:通过code获取access_token****************/
            $result = $this->model->wx->getOauthAccessToken($code);

            //如果发生错误
            if (isset($result['errcode'])) {
                return array('msg'=>'授权失败,请联系客服','result'=>$result);
            }

            //到这一步就说明已经取到了access_token
            $this->wxId = $result['openid'];
            $accessToken = $result['access_token'];
            $openId = $result['openid'];

            //将openid和accesstoken存入cookie中
            $this->input->set_cookie('wx_id', $this->wxId, 60*60*24*7);
            $this->input->set_cookie('access_token', $accessToken);

            /*******************这里开始第三步:通过access_token调用接口,取出用户信息***********************/
            $this->userInfo = $this->model->wx->getUserInfo($openId, $accessToken);

            //自定义微信唯一标识符
            $wxSign =substr(md5($this->wxId.'k2a5dd'), 8, 16);
            //将其存到cookie里
            $this->input->set_cookie('wxSign', $wxSign, 60*60*24*7);
            //将个人信息缓存到redis里
            $this->library->redisCache->set("weixin:sign_{$wxSign}", $userInfo, 60*60*24*7);
            return $userInfo;
        }

    }
?>

获取用户信息的Controller
Copy after login

Controller to obtain user information

WxModel.php

<?php
    class WxModel extends ModelBase{
        public $appId;
        public $appSecret;
        public $token;

        public function __construct() {
            parent::__construct();

            //审核通过的移动应用所给的AppID和AppSecret
            $this->appId = &#39;wx0000000000000000&#39;;
            $this->appSecret = &#39;00000000000000000000000000000&#39;;
            $this->token = &#39;00000000&#39;;
        }


        /**
         * 获取微信授权url
         * @param string 授权后跳转的URL
         * @param bool 是否只获取openid,true时,不会弹出授权页面,但只能获取用户的openid,而false时,弹出授权页面,可以通过openid获取用户信息
         *   
        */
        public function getOAuthUrl($redirectUrl, $openIdOnly, $state = &#39;&#39;) {
            $redirectUrl = urlencode($redirectUrl);
            $scope = $openIdOnly ? &#39;snsapi_base&#39; : &#39;snsapi_userinfo&#39;;
            $oAuthUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$this->appId}&redirect_uri={$redirectUrl}&response_type=code&scope=$scope&state=$state#wechat_redirect";
            return $oAuthUrl;
        }


        /**
        * 获取access_token
        */
        public function getoAuthAccessToken($code) {
            return json_decode(file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid={$this->AppId}&secret={$this->AppSecret}&code={$authCode}&grant_type=authorization_code",true);
        }

        /**
        * 获取用户信息  
        */
        public function getUserInfo($openId, $accessToken) {
            $url = &#39;https://api.weixin.qq.com/sns/userinfo&#39;;
            //获取用户微信账号信息
            $userInfo = $this->callApi("$url?access_token=$accessToken&openid=$openId&lang=zh-CN");

            if ($userInfo[&#39;errcode&#39;]) {
                return array(&#39;msg&#39;=>&#39;获取用户信息失败,请联系客服&#39;, $userInfo);
            }

            $userInfo[&#39;wx_id&#39;] = $openId;

            return $userInfo;
        }

        /**
         * 发起Api请求,并获取返回结果
         * @param string 请求URL
         * @param mixed 请求参数 (array|string)
         * @param string 请求类型 (GET|POST)
         * @return array        
         */
        public function callApi($apiUrl, $param = array(), $method = &#39;GET&#39;) {
            $result = curl_request_json($error, $apiUrl, $params, $method);
            //假如返回的数组有错误码,或者变量$error也有值
            if (!empty($result[&#39;errcode&#39;])) {
                $errorCode = $result[&#39;errcode&#39;];
                $errorMsg = $result[&#39;errmsg&#39;];
            } else if ($error != false) {
                $errorCode = $error[&#39;errorCode&#39;];
                $errorMsg = $error[&#39;errorMessage&#39;];
            }

            if (isset($errorCode)) {
                //将其插入日志文件
                file_put_contents("/data/error.log", "callApi:url=$apiUrl,error=[$errorCode]$errorMsg");

                if ($errorCode === 40001) {
                    //尝试更正access_token后重试
                    try {
                        $pos = strpos(strtolower($url), &#39;access_token=&#39;);
                        if ($pos !==false ) {
                            $pos += strlen(&#39;access_token=&#39;);
                            $pos2 = strpos($apiUrl, &#39;&&#39; ,$pos);
                            $accessTokened = substr($apiUrl, $pos, $pos2 === false ? null : ($pos2 - $pos));
                            return $this->callApi(str_replace($accessTokened, $this->_getApiToken(true), $apiUrl), $param, $method);
                        }
                    }catch (WeixinException $e) { 

                    }
                }
                //这里抛出异常,具有的就不详说了
                throw new WeixinException($errorMessage, $errorCode);
            }
            return $result;
        }

        /**
        * 获取微信 api 的 access_token 。 不同于 OAuth 中的 access_token ,参见  http://mp.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96access_token
        *
        * @param bool 是否强制刷新 accessToken
        */
        private function _getApiToken($forceRefresh = false) {
            //先查看一下redis里是否已经缓存过access_token
            $accessToken = $this->library->redisCache->get(&#39;Weixin:AccessToken&#39;);
            if($forceRefresh || empty($accessToken)) {
                $result = $this->callApi("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appId}&secret={$this->appSecret}");
                $accessToken = $result[&#39;access_token&#39;];
                $expire = max(1, intval($result[&#39;expires_in&#39;]) - 60);
                //将access_token缓存到redis里去
                $this->library->redisCache->set(&#39;Weixin:AccessToken&#39;, $accessToken, $expire);
            }
            return $accessToken;
        }

?>
Copy after login

Model to get user information

Common.php

<?php
    /**
     *   发起一个HTTP(S)请求,并返回json格式的响应数据
     *   @param array 错误信息  array($errorCode, $errorMessage)
     *   @param string 请求Url
     *   @param array 请求参数
     *   @param string 请求类型(GET|POST)
     *   @param int 超时时间
     *   @param array 额外配置
     *   
     *   @return array
     */ 
    public function curl_request_json(&$error, $url, $param = array(), $method = &#39;GET&#39;, $timeout = 10, $exOptions = null) {
        $error = false;
        $responseText = curl_request_text($error, $url, $param, $method, $timeout, $exOptions);
        $response = null;
        if ($error == false && $responseText > 0) {
            $response = json_decode($responseText, true);

            if ($response == null) {
                $error = array(&#39;errorCode&#39;=>-1, &#39;errorMessage&#39;=>&#39;json decode fail&#39;, &#39;responseText&#39;=>$responseText);
                //将错误信息记录日志文件里
                $logText = "json decode fail : $url";
                if (!empty($param)) {
                    $logText .= ", param=".json_encode($param);
                }
                $logText .= ", responseText=$responseText";
                file_put_contents("/data/error.log", $logText);
            }
        }
        return $response;
    }

    /**
    *  发起一个HTTP(S)请求,并返回响应文本
    *   @param array 错误信息  array($errorCode, $errorMessage)
    *   @param string 请求Url
    *   @param array 请求参数
    *   @param string 请求类型(GET|POST)
    *   @param int 超时时间
    *   @param array 额外配置
    *   
    *   @return string
    */
    public function curl_request_text(&$error, $url, $param = array(), $method = &#39;GET&#39;, $timeout = 15, $exOptions = NULL) {
        //判断是否开启了curl扩展
        if (!function_exists(&#39;curl_init&#39;)) exit(&#39;please open this curl extension&#39;);

        //将请求方法变大写
        $method = strtoupper($method);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_HEADER, false);
        if (isset($_SERVER[&#39;HTTP_USER_AGENT&#39;])) curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER[&#39;HTTP_USER_AGENT&#39;]);
        if (isset($_SERVER[&#39;HTTP_REFERER&#39;])) curl_setopt($ch, CURLOPT_REFERER, $_SERVER[&#39;HTTP_REFERER&#39;]);
        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
        switch ($method) {
            case &#39;POST&#39;:
                curl_setopt($ch, CURLOPT_POST, true);
                if (!empty($param)) {
                    curl_setopt($ch, CURLOPT_POSTFIELDS, (is_array($param)) ? http_build_query($param) : $param);
                }
                break;
            
            case &#39;GET&#39;:
            case &#39;DELETE&#39;:
                if ($method == &#39;DELETE&#39;) {
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, &#39;DELETE&#39;);
                }
                if (!empty($param)) {
                    $url = $url.(strpos($url, &#39;?&#39;) ? &#39;&&#39; : &#39;?&#39;).(is_array($param) ? http_build_query($param) : $param);
                }
                break;
        }
        curl_setopt($ch, CURLINFO_HEADER_OUT, true);
        curl_setopt($ch, CURLOPT_URL, $url);
        //设置额外配置
        if (!empty($exOptions)) {
            foreach ($exOptions as $k => $v) {
                curl_setopt($ch, $k, $v);
            }
        }
        $response = curl_exec($ch);

        $error = false;
        //看是否有报错
        $errorCode = curl_errno($ch);
        if ($errorCode) {
            $errorMessage = curl_error($ch);
            $error = array(&#39;errorCode&#39;=>$errorCode, &#39;errorMessage&#39;=>$errorMessage);
            //将报错写入日志文件里
            $logText = "$method $url: [$errorCode]$errorMessage";
            if (!empty($param)) $logText .= ",$param".json_encode($param);
            file_put_contents(&#39;/data/error.log&#39;, $logText);
        }

        curl_close($ch);

        return $response;



    }


?>
Copy after login

Custom function to get user information

 

By calling the interface in the above three steps, the user's WeChat account information can be obtained.

You can take a careful look at the code. I have commented many places in it, making it easy to understand. I hope friends who want to learn can take a closer look.

For more articles related to the WeChat authorized login and access to user information interface, please pay attention to the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP WeChat development: How to implement message encryption and decryption PHP WeChat development: How to implement message encryption and decryption May 13, 2023 am 11:40 AM

PHP is an open source scripting language that is widely used in web development and server-side programming, especially in WeChat development. Today, more and more companies and developers are starting to use PHP for WeChat development because it has become a truly easy-to-learn and easy-to-use development language. In WeChat development, message encryption and decryption are a very important issue because they involve data security. For messages without encryption and decryption methods, hackers can easily obtain the data, posing a threat to users.

Using PHP to develop WeChat mass messaging tools Using PHP to develop WeChat mass messaging tools May 13, 2023 pm 05:00 PM

With the popularity of WeChat, more and more companies are beginning to use it as a marketing tool. The WeChat group messaging function is one of the important means for enterprises to conduct WeChat marketing. However, if you only rely on manual sending, it is an extremely time-consuming and laborious task for marketers. Therefore, it is particularly important to develop a WeChat mass messaging tool. This article will introduce how to use PHP to develop WeChat mass messaging tools. 1. Preparation work To develop WeChat mass messaging tools, we need to master the following technical points: Basic knowledge of PHP WeChat public platform development Development tools: Sub

PHP WeChat development: How to implement user tag management PHP WeChat development: How to implement user tag management May 13, 2023 pm 04:31 PM

In the development of WeChat public accounts, user tag management is a very important function, which allows developers to better understand and manage their users. This article will introduce how to use PHP to implement the WeChat user tag management function. 1. Obtain the openid of the WeChat user. Before using the WeChat user tag management function, we first need to obtain the user's openid. In the development of WeChat public accounts, it is a common practice to obtain openid through user authorization. After the user authorization is completed, we can obtain the user through the following code

PHP WeChat development: How to implement group message sending records PHP WeChat development: How to implement group message sending records May 13, 2023 pm 04:31 PM

As WeChat becomes an increasingly important communication tool in people's lives, its agile messaging function is quickly favored by a large number of enterprises and individuals. For enterprises, developing WeChat into a marketing platform has become a trend, and the importance of WeChat development has gradually become more prominent. Among them, the group sending function is even more widely used. So, as a PHP programmer, how to implement group message sending records? The following will give you a brief introduction. 1. Understand the development knowledge related to WeChat public accounts. Before understanding how to implement group message sending records, I

PHP WeChat development: How to implement customer service chat window management PHP WeChat development: How to implement customer service chat window management May 13, 2023 pm 05:51 PM

WeChat is currently one of the social platforms with the largest user base in the world. With the popularity of mobile Internet, more and more companies are beginning to realize the importance of WeChat marketing. When conducting WeChat marketing, customer service is a crucial part. In order to better manage the customer service chat window, we can use PHP language for WeChat development. 1. Introduction to PHP WeChat development PHP is an open source server-side scripting language that is widely used in the field of Web development. Combined with the development interface provided by WeChat public platform, we can use PHP language to conduct WeChat

PHP WeChat development: How to implement voting function PHP WeChat development: How to implement voting function May 14, 2023 am 11:21 AM

In the development of WeChat public accounts, the voting function is often used. The voting function is a great way for users to quickly participate in interactions, and it is also an important tool for holding events and surveying opinions. This article will introduce you how to use PHP to implement WeChat voting function. Obtain the authorization of the WeChat official account. First, you need to obtain the authorization of the WeChat official account. On the WeChat public platform, you need to configure the API address of the WeChat public account, the official account, and the token corresponding to the public account. In the process of our development using PHP language, we need to use the PH officially provided by WeChat

How to use PHP for WeChat development? How to use PHP for WeChat development? May 21, 2023 am 08:37 AM

With the development of the Internet and mobile smart devices, WeChat has become an indispensable part of the social and marketing fields. In this increasingly digital era, how to use PHP for WeChat development has become the focus of many developers. This article mainly introduces the relevant knowledge points on how to use PHP for WeChat development, as well as some of the tips and precautions. 1. Development environment preparation Before developing WeChat, you first need to prepare the corresponding development environment. Specifically, you need to install the PHP operating environment and the WeChat public platform

PHP WeChat development: How to implement speech recognition PHP WeChat development: How to implement speech recognition May 13, 2023 pm 09:31 PM

With the popularity of mobile Internet, more and more people are using WeChat as a social software, and the WeChat open platform has also brought many opportunities to developers. In recent years, with the development of artificial intelligence technology, speech recognition technology has gradually become one of the popular technologies in mobile terminal development. In WeChat development, how to implement speech recognition has become a concern for many developers. This article will introduce how to use PHP to develop WeChat applications to implement speech recognition functions. 1. Principles of Speech Recognition Before introducing how to implement speech recognition, let us first understand the language

See all articles