-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathPush.php
More file actions
98 lines (90 loc) · 2.52 KB
/
Push.php
File metadata and controls
98 lines (90 loc) · 2.52 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
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
<?php
/**
* Push module
* conversation=> hejinyu
*/
namespace RongCloud\Lib\Push;
use RongCloud\Lib\Request;
use RongCloud\Lib\Utils;
class Push
{
/**
* Push module path
*
* @var string
*/
private $jsonPath = 'Lib/Push/';
/**
* Request configuration file
*
* @var string
*
*/
private $conf = '';
/**
* Verify configuration file
*
* @var string
*/
private $verify = '';
/**
* Push constructor.
*/
function __construct()
{
$this->conf = Utils::getJson($this->jsonPath.'api.json');
$this->verify = Utils::getJson($this->jsonPath.'verify.json');
}
/**
* Broadcast Message
*
* @param array $Push Push parameters
* @param
* $Push = [
* 'platform'=> ['ios','android'],//Target operating systems
* 'fromuserid'=>'mka091amn',//Sender user ID
* 'audience'=>['is_to_all'=>true],//Push conditions, including: tag, userid, is_to_all.
* 'message'=>['content'=>json_encode(['content'=>'1111','extra'=>'aaa']),'objectName'=>'RC:TxtMsg'],//Message content to be sent
* 'notification'=>['alert'=>"this is a push",'ios'=>['alert'=>'abc'],'android'=>['alert'=>'abcd']]//Push display
* ];
* @return array
*/
public function broadcast(array $Push=[]){
$conf = $this->conf['broadcast'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'broadcast',
'data'=> $Push,
'verify'=> $this->verify['broadcast']
]);
if($error) return $error;
$result = (new Request())->Request($conf['url'],$Push,'json');
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* push
*
* @param Push $Push parameter
* @param
* $Push = [
* 'platform'=> ['ios','android'],//Target operating systems
* 'audience'=>['is_to_all'=>true],//Push conditions, including: tag, userid, is_to_all.
* 'notification'=>['alert'=>"this is a push",'ios'=>['alert'=>'abc'],'android'=>['alert'=>'abcd']]//Push display
* ];
* @return array
*/
public function push(array $Push=[]){
$conf = $this->conf['push'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'broadcast',
'data'=> $Push,
'verify'=> $this->verify['push']
]);
if($error) return $error;
$result = (new Request())->Request($conf['url'],$Push,'json');
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
}