- 小程序服务增加数据签名校验

v6
Chaim 4 years ago
parent e3f0d0db79
commit 0f5b71bc40

@ -22,9 +22,6 @@ use DtApp\ThinkLibrary\exception\CurlException;
use DtApp\ThinkLibrary\exception\WeChatException;
use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\curl\HttpService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 微信小程序
@ -83,9 +80,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getPaidUnionId(string $openid)
@ -105,9 +99,6 @@ class MiniService extends Service
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function createWxaQrCode(array $data = [])
@ -129,9 +120,6 @@ class MiniService extends Service
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getWxaCode(array $data = [])
@ -153,9 +141,6 @@ class MiniService extends Service
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getWxaCodeUnLimit(array $data = [])
@ -177,9 +162,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function addTemplate(array $data = [])
@ -200,9 +182,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function deleteTemplate(string $priTmplId)
@ -225,9 +204,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getCategory()
@ -247,9 +223,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getPubTemplateKeyWordsById(string $tid)
@ -273,9 +246,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getPubTemplateTitleList(array $data = [])
@ -295,9 +265,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function getTemplateList()
@ -317,9 +284,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function subscribeMessageSend(array $data = [])
@ -372,9 +336,6 @@ class MiniService extends Service
* @return bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public function accessToken()
@ -383,15 +344,25 @@ class MiniService extends Service
return $this->getAccessToken();
}
/**
* 数据签名校验
* @param string $encrypted_data
* @param string $session_key
* @param string $iv
* @return mixed
*/
public function decode(string $encrypted_data, string $session_key, string $iv)
{
$result = openssl_decrypt(base64_decode($encrypted_data), "AES-128-CBC", base64_decode($session_key), 1, base64_decode($iv));
return json_decode($result, true);
}
/**
* 获取access_token信息
* @return array|bool|mixed|string|string[]
* @throws CacheException
* @throws CurlException
* @throws WeChatException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
private function getAccessToken()
{

Loading…
Cancel
Save