当前位置:网站首页>Laravel8+ wechat applet generates QR code
Laravel8+ wechat applet generates QR code
2022-06-25 06:17:00 【debug013】
First generate access_token
public function getAccessToken()
{
$url ="https://api.weixin.qq.com/cgi-bin/token? grant_type=client_credential&appid=".self::APPID."&secret=".self::SECRET;
$res = (new Curl())->getUrl($url);
return $res['access_token'];
}Generate qr code
public function getXcxCode(Request $request)
{
$access_token = $this->getAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" . $access_token;
$data['scene'] = 'h' . 2;
// Applet details page path
$data['path'] = 'pages/detail/detail';
// QR code size
$data['width'] = '500';
// dd(json_encode($data));
$res = (new Curl())->httpRequest($url,json_encode($data),"POST");
$path = 'upload/' . '2.png';
file_put_contents($path,$res);
$return['status_code'] = 2000;
$return['msg'] = 'ok';
$return['img'] = 'http://www.dome4.com/' . $path;
echo '<img src="'.$return['img'].'" />';
exit;
echo json_encode($return);
exit;
}Simulation of the request
public function httpRequest($url, $data='', $method='GET'){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
if($method=='POST')
{
curl_setopt($curl, CURLOPT_POST, 1);
if ($data != '')
{
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
边栏推荐
- Some common errors and solutions of using SAP ui5 to consume OData services
- Research Report on global and Chinese vaccine market profit forecast and the 14th five year plan development strategy 2022-2028
- Huawei machine test question: splicing URL
- Part 34 of SAP ui5 application development tutorial - device adaptation of SAP ui5 application based on device type
- Lesson 9: workspace introduction
- Methods for obtaining some information of equipment
- Global and Chinese benzoic acid market competition strategy and demand scale forecast report 2022
- SAP ui5 application development tutorial XXIX - Introduction to routing and navigation functions of SAP ui5 trial version
- Ping command – test network connectivity between hosts
- Global and Chinese medical protective clothing market supply and demand research and investment value proposal report 2022-2028
猜你喜欢
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!
SAP ui5 date type sap ui. model. type. Analysis of date parsing format
Configuration file ui5 local in SAP ui5 tools Configuration points of yaml

ctfshow-misc
Yunda's cloud based business in Taiwan construction 𞓜 practical school

C simple operation mongodb
What changes have taken place in the project file after SAP ui5 tools ran the Fiori add deploy config command
Part 33 of SAP ui5 application development tutorial - trial version of responsiveness of SAP ui5 applications

Gb28181 protocol -- timing
MySQL transaction learning notes (I) first encounter
随机推荐
Research Report on demand and Competitive Prospect of global and Chinese welding personal protective equipment industry 2022-2027
A + B Again
Day22 send request and parameterization using JMeter
C simple operation mongodb
SAP ui5 tutorial for beginners part XXVI - detailed steps for using OData service with mock server trial version
SAP ui5 beginner tutorial No. 28 - Introduction to the integration test tool OPA for SAP ui5 applications
Lesson 9: workspace introduction
The sum problem
Go quiz: considerations for function naming return value from the go interview question (more than 80% of people answered wrong)
Technology inventory: past, present and future of Message Oriented Middleware
[Suanli network] problems and challenges faced by the development of Suanli network
Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop
Understanding the dynamic mode of mongodb document
The elephant turns around and starts the whole body. Ali pushes Maoxiang not only to Jingdong
General test point ideas are summarized and shared, which can be directly used in interview and actual software testing
Socket, network model notes
Monitoring access: how to grant minimum WMI access to the monitoring service account
No one reads the series. Source code analysis of copyonwritearraylist
SAP ui5 application development tutorial XXIX - Introduction to routing and navigation functions of SAP ui5 trial version
Technology inventory: Technology Evolution and Future Trend Outlook of cloud native Middleware