Wechat.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @remark :
* @name :Wechat.php
* @author :lyh
* @method :post
* @time :2023/8/23 18:18
*/
namespace App\Helper;
use \GuzzleHttp\Client;
use Illuminate\Support\Facades\Cache;
/**
* @remark :微信相关
* @name :Wechat
* @author :lyh
* @method :post
* @time :2023/8/23 18:19
*/
class Wechat
{
public $alias = '_v6-test';
public $appid = 'wx8253a38fd7ae78f0';
public $appSecret = '20981cca3d00c074a8886f115d19548d';
/**
* @remark :生成access_token
* @name :getAccessToken
* @author :lyh
* @method :post
* @time :2023/8/23 18:28
*/
public function getAccessToken()
{
$token = file_get_contents("http://wechat.globalso.com/api/accesstoken/v6-test");
return $token;
}
/**
* @remark :生成二维码
* @name :setQrcode
* @author :lyh
* @method :post
* @time :2023/8/23 18:19
*/
public function setQrcode($type,$accessToken){
$url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $accessToken;
$client = new Client();
$response = $client->post($url, [
'json' => [
'expire_seconds' => 3600,
'action_name' => 'QR_STR_SCENE',
'action_info' => [
'scene' => [
'scene_str' => $type.$this->alias,
],
],
],
]);
$data = json_decode($response->getBody(), true);
return $data;
}
}