Beispiel #1
0
 /**
  *  获取校验结果
  * @param $ssid
  * @param $result
  * @param int $diff
  * @return type
  */
 public static function sendVerifyRemoteRequest($ssid, $result, $diff = 0)
 {
     $client = new HttpClient(App::getConfig('YUC_SERVICE_NAME'), App::getConfig('YUC_SERVICE_PORT'));
     $client->setTimeout(App::getConfig('YUC_CLIENT_TIMEOUT'));
     //设置超时
     $client->post(App::getConfig('YUC_VERIFY_PATH'), array('site_key' => App::getConfig('YUC_SITE_KEY'), 'ssid' => $ssid, 'result' => $result, 'diffsec_client' => $diff));
     $post_req = json_decode($client->getContent(), TRUE);
     Log::Write('远程验证完成,输入结果为:' . $result . ',返回状态 :' . $client->getStatus() . ';' . 'POST 验证码正确性请求返回的数据:' . $client->getContent(), Log::DEBUG);
     if ($client->getStatus() == 200 && is_array($post_req)) {
         //200状态 正常返回数据 且返回数据格式正常
         self::$_yuc_code = $post_req['code'];
         self::$_yuc_details = $post_req['details'];
         self::$_yuc_result = $post_req['result'];
     } else {
         self::$_yuc_code = 'E_SEVERVALID_001';
         self::$_yuc_details = '服务器请求失败!';
         self::$_yuc_result = 0;
     }
     return array('code' => self::$_yuc_code, 'result' => self::$_yuc_result, 'details' => self::$_yuc_details);
 }