@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | |
31 | 31 | protected function doRequest($type, $endpoint, $params=array()) |
32 | 32 | { |
33 | - $base = ($this->useSSL) ? "https" : "http"; |
|
34 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
35 | - $headers = array( |
|
36 | - 'Accept' => 'application/json', |
|
37 | - 'Authorization' => $this->secret |
|
38 | - ); |
|
33 | + $base = ($this->useSSL) ? "https" : "http"; |
|
34 | + $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
35 | + $headers = array( |
|
36 | + 'Accept' => 'application/json', |
|
37 | + 'Authorization' => $this->secret |
|
38 | + ); |
|
39 | 39 | |
40 | 40 | $body = json_encode($params); |
41 | 41 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function getUsers() |
77 | 77 | { |
78 | - $endpoint = '/users'; |
|
79 | - return $this->doRequest('get',$endpoint); |
|
78 | + $endpoint = '/users'; |
|
79 | + return $this->doRequest('get',$endpoint); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | return $this->doRequest('put', $endpoint, compact('username', 'password','name','email', 'groups')); |
138 | 138 | } |
139 | 139 | |
140 | - /** |
|
141 | - * locks/Disables an OpenFire user |
|
142 | - * |
|
143 | - * @param string $username Username |
|
144 | - * @return json|false Json with data or error, or False when something went fully wrong |
|
145 | - */ |
|
140 | + /** |
|
141 | + * locks/Disables an OpenFire user |
|
142 | + * |
|
143 | + * @param string $username Username |
|
144 | + * @return json|false Json with data or error, or False when something went fully wrong |
|
145 | + */ |
|
146 | 146 | public function lockoutUser($username) |
147 | 147 | { |
148 | 148 | $endpoint = '/lockouts/'.$username; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public $plugin = '/plugins/restapi/v1'; |
12 | 12 | public $secret = 'SuperSecret'; |
13 | 13 | public $useSSL = false; |
14 | - protected $params = array(); |
|
14 | + protected $params = array(); |
|
15 | 15 | public $client; |
16 | 16 | |
17 | 17 | public function __construct() |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | * @return array|false Array with data or error, or False when something went fully wrong |
29 | 29 | */ |
30 | 30 | |
31 | - protected function doRequest($type, $endpoint, $params=array()) |
|
31 | + protected function doRequest($type, $endpoint, $params = array()) |
|
32 | 32 | { |
33 | 33 | $base = ($this->useSSL) ? "https" : "http"; |
34 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
34 | + $url = $base."://".$this->host.":".$this->port.$this->plugin.$endpoint; |
|
35 | 35 | $headers = array( |
36 | 36 | 'Accept' => 'application/json', |
37 | 37 | 'Authorization' => $this->secret |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | $result = $this->client->get($url, compact('headers')); |
45 | 45 | break; |
46 | 46 | case 'post': |
47 | - $headers += ['Content-Type'=>'application/json']; |
|
48 | - $result = $this->client->post($url, compact('headers','body')); |
|
47 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
48 | + $result = $this->client->post($url, compact('headers', 'body')); |
|
49 | 49 | break; |
50 | 50 | case 'delete': |
51 | - $headers += ['Content-Type'=>'application/json']; |
|
52 | - $result = $this->client->delete($url, compact('headers','body')); |
|
51 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
52 | + $result = $this->client->delete($url, compact('headers', 'body')); |
|
53 | 53 | break; |
54 | 54 | case 'put': |
55 | - $headers += ['Content-Type'=>'application/json']; |
|
56 | - $result = $this->client->put($url, compact('headers','body')); |
|
55 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
56 | + $result = $this->client->put($url, compact('headers', 'body')); |
|
57 | 57 | break; |
58 | 58 | default: |
59 | 59 | $result = null; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function getUsers() |
77 | 77 | { |
78 | 78 | $endpoint = '/users'; |
79 | - return $this->doRequest('get',$endpoint); |
|
79 | + return $this->doRequest('get', $endpoint); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | * @param string[]|false $groups Groups (Optional) |
103 | 103 | * @return json|false Json with data or error, or False when something went fully wrong |
104 | 104 | */ |
105 | - public function addUser($username, $password, $name=false, $email=false, $groups=false) |
|
105 | + public function addUser($username, $password, $name = false, $email = false, $groups = false) |
|
106 | 106 | { |
107 | 107 | $endpoint = '/users'; |
108 | - return $this->doRequest('post', $endpoint, compact('username', 'password','name','email', 'groups')); |
|
108 | + return $this->doRequest('post', $endpoint, compact('username', 'password', 'name', 'email', 'groups')); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | * @param string[]|false $groups Groups (Optional) |
132 | 132 | * @return json|false Json with data or error, or False when something went fully wrong |
133 | 133 | */ |
134 | - public function updateUser($username, $password, $name=false, $email=false, $groups=false) |
|
134 | + public function updateUser($username, $password, $name = false, $email = false, $groups = false) |
|
135 | 135 | { |
136 | 136 | $endpoint = '/users/'.$username; |
137 | - return $this->doRequest('put', $endpoint, compact('username', 'password','name','email', 'groups')); |
|
137 | + return $this->doRequest('put', $endpoint, compact('username', 'password', 'name', 'email', 'groups')); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | * @param int|false $subscriptionType Subscription (Optional) |
173 | 173 | * @return json|false Json with data or error, or False when something went fully wrong |
174 | 174 | */ |
175 | - public function addToRoster($username, $jid, $name=false, $subscriptionType=false) |
|
175 | + public function addToRoster($username, $jid, $name = false, $subscriptionType = false) |
|
176 | 176 | { |
177 | 177 | $endpoint = '/users/'.$username.'/roster'; |
178 | - return $this->doRequest('post', $endpoint, compact('jid','name','subscriptionType')); |
|
178 | + return $this->doRequest('post', $endpoint, compact('jid', 'name', 'subscriptionType')); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | * @param int|false $subscriptionType Subscription (Optional) |
202 | 202 | * @return json|false Json with data or error, or False when something went fully wrong |
203 | 203 | */ |
204 | - public function updateRoster($username, $jid, $nickname=false, $subscriptionType=false) |
|
204 | + public function updateRoster($username, $jid, $nickname = false, $subscriptionType = false) |
|
205 | 205 | { |
206 | 206 | $endpoint = '/users/'.$username.'/roster/'.$jid; |
207 | - return $this->doRequest('put', $endpoint, $jid, compact('jid','username','subscriptionType')); |
|
207 | + return $this->doRequest('put', $endpoint, $jid, compact('jid', 'username', 'subscriptionType')); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | public function createGroup($name, $description = false) |
242 | 242 | { |
243 | 243 | $endpoint = '/groups/'; |
244 | - return $this->doRequest('post', $endpoint, compact('name','description')); |
|
244 | + return $this->doRequest('post', $endpoint, compact('name', 'description')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * @param string $description Some description of the group |
264 | 264 | * |
265 | 265 | */ |
266 | - public function updateGroup($name, $description) |
|
266 | + public function updateGroup($name, $description) |
|
267 | 267 | { |
268 | 268 | $endpoint = '/groups/'.$name; |
269 | - return $this->doRequest('put', $endpoint, compact('name','description')); |
|
269 | + return $this->doRequest('put', $endpoint, compact('name', 'description')); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |