static function getIDInfo($id) { $paramArr = array('showapi_appid' => ShowApiSdk::$showapi_appid, 'id' => $id, 'showapi_timestamp' => date('YmdHis')); $sign = ShowApiSdk::createSign($paramArr); $strParam = ShowApiSdk::createStrParam($paramArr); $strParam .= 'showapi_sign=' . $sign; $url = 'http://route.showapi.com/25-3?' . $strParam; $result = file_get_contents($url); $result = json_decode($result); if (intval($result->showapi_res_code) == 0) { if ($result->showapi_res_body->retMsg == "success") { return $result->showapi_res_body->retData; } } else { return ''; } }
public function respond() { global $_W, $_GPC; if (!$this->inContext) { $this->beginContext(); return $this->respText('请输入要查询的身份证号码:'); } else { $id = trim($this->message['content']); $info = ShowApiSdk::getIDInfo($id); $str = ""; if ($info != "" && is_object($info)) { $str = "地址:" . $info->address . "\r\n" . "生日:" . $info->birthday . "\r\n" . "性别:" . ($info->sex == "F" ? "男" : "女"); } if ($str != "" && strlen($str) > 6) { $this->endContext(); return $this->respText("查询到的信息\r\n" . $str); } else { return $this->respText("请确认您输入的号码是否正确,检查后重试吧"); } } }