-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Helperhaps
committed
Dec 15, 2017
1 parent
921b491
commit dd03e86
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
// 这只是使用样例,不应该直接用于实际生产环境中 !! | ||
|
||
require 'config.php'; | ||
|
||
use JPush\AdminClient as Admin; | ||
|
||
$admin = new Admin($dev_key, $dev_secret); | ||
$response = $admin->createApp('aaa', 'cn.jpush.app'); | ||
print_r($response); | ||
|
||
$appKey = $response['body']['app_key']; | ||
$response = $admin->deleteApp($appKey); | ||
print_r($response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
namespace JPush; | ||
|
||
class AdminClient { | ||
|
||
const ADMIN_URL = 'https://admin.jpush.cn/v1/app/'; | ||
|
||
private $devKey; | ||
private $devSecret; | ||
private $retryTimes; | ||
private $logFile; | ||
|
||
function __construct($devKey, $devSecret) { | ||
if (!is_string($devKey) || !is_string($devSecret)) { | ||
throw new InvalidArgumentException("Invalid devKey or devSecret"); | ||
} | ||
$this->devKey = $devKey; | ||
$this->devSecret = $devSecret; | ||
$this->retryTimes = 1; | ||
$this->logFile = null; | ||
} | ||
|
||
public function getAuthStr() { return $this->devKey . ":" . $this->devSecret; } | ||
public function getRetryTimes() { return $this->retryTimes; } | ||
public function getLogFile() { return $this->logFile; } | ||
|
||
public function createApp($appName, $androidPackage, $groupName=null) { | ||
$url = AdminClient::ADMIN_URL; | ||
$body = [ | ||
'app_name' => $appName, | ||
'android_package'=> $androidPackage, | ||
'group_name' => $groupName | ||
|
||
]; | ||
return Http::post($this, $url, $body); | ||
} | ||
|
||
public function deleteApp($appKey) { | ||
$url = AdminClient::ADMIN_URL . $appKey . '/delete'; | ||
return Http::post($this, $url, []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
namespace JPush; | ||
|
||
const VERSION = '3.5.23'; | ||
const VERSION = '3.5.24'; |