In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
WeChat Mini Programs how to generate Mini Program QR code with parameters, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail, people with this need can come to learn, I hope you can get something.
Officially, there are two ways to generate mini codes: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
Https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html
The server generates mini code
/ / small program code public function getWxcode () {$ACCESS_TOKEN = $this- > getWxAccessToken (); $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=". $ACCESS_TOKEN ['access_token']; $post_data = array (' page' = > 'pages/my/my', / / scan Code Jump Page' scene' = > input ('invite_code') / / user invitation code); $post_data = json_encode ($post_data); $data = $this- > send_post ($url, $post_data) $result = $this- > data_uri ($data, 'image/png'); return''; / / return $result;} private function getWxAccessToken () {$appid ='*'; $appsecret ='*'; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=". $appid. & secret=. $appsecret; $access_token = $this- > makeRequest ($url); $access_token = json_decode ($access_token ['result'], true); return $access_token } / * initiate a http request * @ param string $url access path * @ param array $params parameter, which has more than one array, indicating that the address returned for POST * @ param int $expire request timeout * @ param array $extend request forged packet header parameter * @ param string $hostIp HOST * @ return array is a request status A content * / private function makeRequest ($url, $params = array (), $expire = 0, $extend = array (), $hostIp =') {if (empty ($url)) {return array ('code' = >' 100') } $_ curl = curl_init (); $_ header = array ('Accept-Language: zh-CN',' Connection: Keep-Alive', 'Cache-Control: no-cache'); / / facilitate direct access to the address if (! empty ($hostIp)) where the host is to be set) {$urlInfo = parse_url ($url) If (empty ($urlInfo ['host'])) {$urlInfo [' host'] = substr (DOMAIN, 7,-1); $url = "http://{$hostIp}{$url}";} else {$url = str_replace ($urlInfo ['host'], $hostIp, $url);} $header [] =" Host: {$urlInfo [' host']} " } / / as long as the second parameter passes a value, it is POST's if (! empty ($params)) {curl_setopt ($_ curl, CURLOPT_POSTFIELDS, http_build_query ($params)); curl_setopt ($_ curl, CURLOPT_POST, true);} if (substr ($url, 0,8) = 'https://') {curl_setopt ($_ curl, CURLOPT_SSL_VERIFYPEER, FALSE)) Curl_setopt ($_ curl, CURLOPT_SSL_VERIFYHOST, FALSE);} curl_setopt ($_ curl, CURLOPT_URL, $url); curl_setopt ($_ curl, CURLOPT_RETURNTRANSFER, true); curl_setopt ($_ curl, CURLOPT_USERAGENT, 'API PHP CURL'); curl_setopt ($_ curl, CURLOPT_HTTPHEADER, $_ header); if ($expire > 0) {curl_setopt ($_ curl, CURLOPT_TIMEOUT, $expire) / / processing timeout curl_setopt ($_ curl, CURLOPT_CONNECTTIMEOUT, $expire); / / establishing connection timeout} / / additional configuration if (! empty ($extend)) {curl_setopt_array ($_ curl, $extend);} $result ['result'] = curl_exec ($_ curl); $result [' code'] = curl_getinfo ($_ curl, CURLINFO_HTTP_CODE) $result ['info'] = curl_getinfo ($_ curl); if ($result [' result'] = false) {$result ['result'] = curl_error ($_ curl); $result [' code'] =-curl_errno ($_ curl);} curl_close ($_ curl); return $result } / * message push http * @ param $url * @ param $post_data * @ return bool | string * / private function send_post ($url, $post_data) {$options = array ('http' = > array (' method' = > POST', 'header' = >' Content-type:application/json', / / header needs to be set to JSON 'content' = > $post_data 'timeout' = > 60 / / timeout)) $context = stream_context_create ($options); $result = file_get_contents ($url, false, $context); return $result;} / / binary transfer image/pngprivate function data_uri ($contents, $mime) {$base64 = base64_encode ($contents); return (_ 'data:'. $mime. '; base64,'. $base64);} is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.