$card_no, 'appid' => self::APPID]; $params['sign'] = $this->sign($params); $resp = http_request(self::OPENAPI_URL,$params); if(empty($resp)) { return [false,[]]; } $resp = json_decode($resp, true); if ($resp['code'] == 200) { $result = $resp['data']; return [true, $result]; } else { return [false, []]; } } private function sign($input) { $body = $this->body($input); $body .= "&key=" . self::SECURE; return md5($body); } private function check_empty($value) { if (!isset($value)) return true; if ($value === null) return true; if (trim($value) === "") return true; return false; } 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; } }