|
@@ -16,6 +16,7 @@ class JPushService
|
|
const PUSH_TYPE_TAG = 2;
|
|
const PUSH_TYPE_TAG = 2;
|
|
const PUSH_TYPE_ALIAS = 3;
|
|
const PUSH_TYPE_ALIAS = 3;
|
|
const PUSH_TYPE_REG_ID = 4;
|
|
const PUSH_TYPE_REG_ID = 4;
|
|
|
|
+ const JG_YJDL_POST_URL = 'https://api.verification.jpush.cn/v1/web/loginTokenVerify';
|
|
|
|
|
|
private function __construct()
|
|
private function __construct()
|
|
{
|
|
{
|
|
@@ -193,12 +194,12 @@ class JPushService
|
|
* err:错误信息
|
|
* err:错误信息
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- public function jgOpensslPrivateDecrypt($encrypted){
|
|
|
|
|
|
+ public static function jgOpensslPrivateDecrypt($encrypted){
|
|
$prefix = '-----BEGIN RSA PRIVATE KEY-----';
|
|
$prefix = '-----BEGIN RSA PRIVATE KEY-----';
|
|
$suffix = '-----END RSA PRIVATE KEY-----';
|
|
$suffix = '-----END RSA PRIVATE KEY-----';
|
|
$result = '';
|
|
$result = '';
|
|
|
|
|
|
- $prikey = JG_YJDL_PRIVATE_RSA;
|
|
|
|
|
|
+ $prikey = config('jpush.jg_yjdl_private_rsa');
|
|
|
|
|
|
$key = $prefix . "\n" . $prikey . "\n" . $suffix;//拼接换行符
|
|
$key = $prefix . "\n" . $prikey . "\n" . $suffix;//拼接换行符
|
|
$r = openssl_private_decrypt(base64_decode($encrypted), $result, openssl_pkey_get_private($key));
|
|
$r = openssl_private_decrypt(base64_decode($encrypted), $result, openssl_pkey_get_private($key));
|
|
@@ -219,13 +220,13 @@ class JPushService
|
|
* err:错误信息
|
|
* err:错误信息
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- public function jgLoginTokenVerify($token,$exId)
|
|
|
|
|
|
+ public static function jgLoginTokenVerify($token,$exId)
|
|
{
|
|
{
|
|
- $host = JG_YJDL_POST_URL;
|
|
|
|
|
|
+ $host = self::JG_YJDL_POST_URL;
|
|
$method = "POST";
|
|
$method = "POST";
|
|
- $appcode = VERIFY_APPCODE;
|
|
|
|
|
|
+// $appcode = VERIFY_APPCODE;
|
|
$headers = array();
|
|
$headers = array();
|
|
- array_push($headers, "Authorization: Basic " .base64_encode(JG_APPKEY.':'.JG_MASTERSECRET));
|
|
|
|
|
|
+ array_push($headers, "Authorization: Basic " .base64_encode(config('jpush.app_key').':'.config('jpush.master_secret')));
|
|
//根据API的要求,定义相对应的Content-Type
|
|
//根据API的要求,定义相对应的Content-Type
|
|
array_push($headers, "Content-Type".":"."application/json");
|
|
array_push($headers, "Content-Type".":"."application/json");
|
|
|
|
|
|
@@ -246,11 +247,7 @@ class JPushService
|
|
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|
|
|
|
|
// file_put_contents(PATH_USER_JG_LOGIN_LOG.date('Y-m-d').'.log', date('Y-m-d H:i:s').$ret.PHP_EOL,FILE_APPEND);//写入文件 常量需要自己在定义
|
|
// file_put_contents(PATH_USER_JG_LOGIN_LOG.date('Y-m-d').'.log', date('Y-m-d H:i:s').$ret.PHP_EOL,FILE_APPEND);//写入文件 常量需要自己在定义
|
|
-
|
|
|
|
$ret = json_decode($ret,true);
|
|
$ret = json_decode($ret,true);
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
if ($ret['code'] == 8000) {
|
|
if ($ret['code'] == 8000) {
|
|
if($ret['exID']!=$exId){
|
|
if($ret['exID']!=$exId){
|
|
$ret['err'] = 'exID 返回与发送不一致';
|
|
$ret['err'] = 'exID 返回与发送不一致';
|
|
@@ -259,8 +256,6 @@ class JPushService
|
|
} else {
|
|
} else {
|
|
$ret['err'] = $ret['code'].':'.$ret['content'];
|
|
$ret['err'] = $ret['code'].':'.$ret['content'];
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
return $ret;
|
|
return $ret;
|
|
|
|
|
|
|
|
|