File tree Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ // 这只是使用样例,不应该直接用于实际生产环境中 !!
3
+
4
+ require 'config.php ' ;
5
+
6
+ use JPush \AdminClient as Admin ;
7
+
8
+ $ admin = new Admin ($ dev_key , $ dev_secret );
9
+ $ response = $ admin ->createApp ('aaa ' , 'cn.jpush.app ' );
10
+ print_r ($ response );
11
+
12
+ $ appKey = $ response ['body ' ]['app_key ' ];
13
+ $ response = $ admin ->deleteApp ($ appKey );
14
+ print_r ($ response );
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace JPush ;
3
+
4
+ class AdminClient {
5
+
6
+ const ADMIN_URL = 'https://admin.jpush.cn/v1/app/ ' ;
7
+
8
+ private $ devKey ;
9
+ private $ devSecret ;
10
+ private $ retryTimes ;
11
+ private $ logFile ;
12
+
13
+ function __construct ($ devKey , $ devSecret ) {
14
+ if (!is_string ($ devKey ) || !is_string ($ devSecret )) {
15
+ throw new InvalidArgumentException ("Invalid devKey or devSecret " );
16
+ }
17
+ $ this ->devKey = $ devKey ;
18
+ $ this ->devSecret = $ devSecret ;
19
+ $ this ->retryTimes = 1 ;
20
+ $ this ->logFile = null ;
21
+ }
22
+
23
+ public function getAuthStr () { return $ this ->devKey . ": " . $ this ->devSecret ; }
24
+ public function getRetryTimes () { return $ this ->retryTimes ; }
25
+ public function getLogFile () { return $ this ->logFile ; }
26
+
27
+ public function createApp ($ appName , $ androidPackage , $ groupName =null ) {
28
+ $ url = AdminClient::ADMIN_URL ;
29
+ $ body = [
30
+ 'app_name ' => $ appName ,
31
+ 'android_package ' => $ androidPackage ,
32
+ 'group_name ' => $ groupName
33
+
34
+ ];
35
+ return Http::post ($ this , $ url , $ body );
36
+ }
37
+
38
+ public function deleteApp ($ appKey ) {
39
+ $ url = AdminClient::ADMIN_URL . $ appKey . '/delete ' ;
40
+ return Http::post ($ this , $ url , []);
41
+ }
42
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace JPush ;
3
3
4
- const VERSION = '3.5.23 ' ;
4
+ const VERSION = '3.5.24 ' ;
You can’t perform that action at this time.
0 commit comments