不废话直接上代码
1.二维码业务类
<?php
/**
* User : 张纯泽
* Date : 2020/6/11
* Time : 9:20
*/
namespace app\api\service;
class Wxcode
{
public function getAccesstoken(){
$appid = ''; /*小程序appid*/
$srcret = ''; /*小程序秘钥*/
$tokenUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$srcret;
$getArr=array();
$tokenArr=json_decode($this->send_post($tokenUrl,$getArr,"GET"));
$access_token=$tokenArr->access_token;
return $access_token;
}
public function send_post($url, $post_data,$method='POST') {
$postdata = http_build_query($post_data);
$options = array(
'http' => array(
'method' => $method, //or GET
'header' => 'Cont