-
Notifications
You must be signed in to change notification settings - Fork 0
/wechat
Copy pathexecutable file
·120 lines (98 loc) · 2.71 KB
/wechat
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env php
<?php
// by @leaskh
error_reporting(E_ALL ^ E_NOTICE);
define('HELPER_DIR', dirname(__FILE__) . '/helpers');
define('MODEL_DIR', dirname(__FILE__) . '/models');
set_time_limit(10);
require_once dirname(__FILE__) . '/common.php';
require_once dirname(__FILE__) . '/DataModel.php';
require_once 'FrontController.php';
class wechatcli extends DataModel {
public $hlpWechat = null;
public function __construct() {
$this->hlpWechat = $this->getHelperByName('Wechat');
}
public function getMenu() {
$rawMenu = $this->hlpWechat->getMenu();
if ($rawMenu) {
print_r($rawMenu);
} else {
echo "menu no exist!\r\n";
}
}
public function createMenu() {
$menu = [
"button" => [
[
"type" => "click",
"name" => "查看",
"key" => "LIST_MAPS",
],
[
"type" => "click",
"name" => "创建",
"key" => "CREATE_MAP",
],
[
"type" => "click",
"name" => "···",
"key" => "MORE",
]
]
];
$rawMenu = $this->hlpWechat->createMenu($menu);
if ($rawMenu) {
print_r($rawMenu);
} else {
echo "Failed!\r\n";
}
}
public function updateMenu() {
$rawResult = $this->hlpWechat->deleteMenu();
if ($rawResult) {
$this->createMenu();
} else {
echo "Failed!\r\n";
}
}
public function deleteMenu() {
$rawResult = $this->hlpWechat->deleteMenu();
if ($rawResult) {
echo "Done!\r\n";
} else {
echo "Failed!\r\n";
}
}
public function test() {
$rawUser = $this->hlpWechat->getIdentityBy('onrOgjiSR2kTBaJISb32-z8cpbzA@gh_8c4c8d9d14a7');
if ($rawUser) {
print_r($rawUser);
} else {
echo "Failed!\r\n";
}
}
}
$objWechatcli = new wechatcli();
array_shift($argv);
switch (strtolower($argv[0])) {
case 'getmenu':
$objWechatcli->getMenu();
break;
case 'createmenu':
$objWechatcli->createMenu();
break;
case 'updatemenu':
$objWechatcli->updateMenu();
break;
case 'deletemenu':
$objWechatcli->deleteMenu();
break;
case 'test':
$objWechatcli->test();
break;
default:
echo "WeChatCli: invalid option -- '{$argv[0]}'\r\n";
echo "try: getmenu, createmenu, updatemenu, deletemenu, test.\r\n";
exit(1);
}