|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the overtrue/wechat. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) lxm <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace EasyWeChat\MiniProgram\OpenData; |
|
13
|
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Client. |
|
18
|
|
|
* |
|
19
|
|
|
* @author tianyong90 <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class Client extends BaseClient |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $baseUri = 'https://api.weixin.qq.com/wxa/'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* removeUserStorage. |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $openid |
|
32
|
|
|
* @param string $sessionKey |
|
33
|
|
|
* @param array $key |
|
34
|
|
|
* |
|
35
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
36
|
|
|
* |
|
37
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
38
|
|
|
*/ |
|
39
|
|
|
public function removeUserStorage(string $openid, string $sessionKey, array $key) |
|
40
|
|
|
{ |
|
41
|
|
|
$data = ['key' => $key]; |
|
|
|
|
|
|
42
|
|
|
$query = [ |
|
43
|
|
|
'appid' => $this->app['config']['app_id'], |
|
44
|
|
|
'secret' => $this->app['config']['secret'], |
|
45
|
|
|
'openid' => $openid, |
|
46
|
|
|
'sig_method' => 'hmac_sha256', |
|
47
|
|
|
'signature' => hash_hmac('sha256', json_encode($data), $sessionKey), |
|
48
|
|
|
]; |
|
49
|
|
|
return $this->httpPostJson('remove_user_storage', $data, $query); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* setUserStorage. |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $openid |
|
56
|
|
|
* @param string $sessionKey |
|
57
|
|
|
* @param array $kvList |
|
58
|
|
|
* |
|
59
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
60
|
|
|
* |
|
61
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
62
|
|
|
*/ |
|
63
|
|
|
public function setUserStorage(string $openid, string $sessionKey, array $kvList) |
|
64
|
|
|
{ |
|
65
|
|
|
$data = ['kv_list' => $kvList]; |
|
|
|
|
|
|
66
|
|
|
$query = [ |
|
67
|
|
|
'appid' => $this->app['config']['app_id'], |
|
68
|
|
|
'secret' => $this->app['config']['secret'], |
|
69
|
|
|
'openid' => $openid, |
|
70
|
|
|
'sig_method' => 'hmac_sha256', |
|
71
|
|
|
'signature' => hash_hmac('sha256', json_encode($data), $sessionKey), |
|
72
|
|
|
]; |
|
73
|
|
|
return $this->httpPostJson('set_user_storage', $data, $query); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.