|
@@ -0,0 +1,47 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace mtopcard;
|
|
|
+
|
|
|
+class open_query
|
|
|
+{
|
|
|
+ private const OPENAPI_URL = 'https://openapi.xyzshops.cn/api.php/CardInfo/query';
|
|
|
+ private const APPID = 'ea97586b4aa0c141e4456912f3325f7f';
|
|
|
+ private const SECURE = '92c51d28e3405c923decf1b333cec3ce';
|
|
|
+
|
|
|
+ public function validate($card_no)
|
|
|
+ {
|
|
|
+ $params = ['cardno' => $card_no, 'appid' => self::APPID];
|
|
|
+ $params['sign'] = $this->sign($params);
|
|
|
+
|
|
|
+ $resp = http_request(self::OPENAPI_URL,$params);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sign($input)
|
|
|
+ {
|
|
|
+ $body = $this->body($input);
|
|
|
+ $body .= "&key=" . self::SECURE;
|
|
|
+
|
|
|
+ return md5($body);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function body($params)
|
|
|
+ {
|
|
|
+ ksort($params);
|
|
|
+ $body = "";
|
|
|
+ $i = 0;
|
|
|
+ foreach ($params as $k => $v)
|
|
|
+ {
|
|
|
+ if (false === $this->check_empty($v) && "@" != substr($v, 0, 1))
|
|
|
+ {
|
|
|
+ if ($i == 0) {
|
|
|
+ $body .= "$k" . "=" . urlencode($v);
|
|
|
+ } else {
|
|
|
+ $body .= "&" . "$k" . "=" . urlencode($v);
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $body;
|
|
|
+ }
|
|
|
+}
|