极光一键登录 鉴别token
public function checkMobile($token)
{
$data['loginToken'] = $token;
$data['exID'] = '';//我的默认为空
$data = json_encode($data);
$url = 'https://api.verification.jpush.cn/v1/web/loginTokenVerify';
$res = $this->postCurl($url, $data);
dd($res);
if ($res['code'] != 8000) {
self::$error = '认证失败';
return false;
}//认证成功对手机号解密
$prefix = '-----BEGIN RSA PRIVATE KEY-----';
$suffix = '-----END RSA PRIVATE KEY-----';
$result = '';
$encrypted = $res['phone'];
$prikey = '你的私钥';
$key = $prefix . "\n" . $prikey . "\n" . $suffix;
$r = openssl_private_decrypt(base64_decode($encrypted), $result, openssl_pkey_get_private($key));
return $result;
}
public function postCurl($url, $data)
{
//官方文档 获取appkey、masterSecret的值
//http://docs.jiguang.cn/jverification/server/rest_api/rest_api_summary
$appKey = 'appKey的值';
$masterSecret = 'masterSecret的值';
$base = base64_encode("{$appKey}:{$masterSecret}");
$add = "Authorization: Basic " . $base;
$headerArray = array("Content-type:application/json", $add);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headerArray);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
$result = json_decode($output, true);
return $result;
}
觉得有用请点击呦