コード例 #1
0
ファイル: MMapApiQq.php プロジェクト: noikiy/wowewe
 public function submit($url, $params)
 {
     try {
         $requestUrl = $url . '?';
         if ($this->method == 'GET') {
             $requestUrl .= http_build_query($params);
             $postFields = null;
         } else {
             $postFields = $params;
         }
         $resp = U::curl($requestUrl, $postFields);
     } catch (Exception $e) {
         U::W($e->getCode() . ':' . $e->getMessage());
         return ['errcode' => $e->getCode(), 'errmsg' => $e->getMessage()];
     }
     if ("json" === $this->format) {
         $arr = json_decode($resp, true);
         if (null !== $arr) {
             return $arr;
         }
     } else {
         if ("xml" === $this->format) {
             $respObject = @simplexml_load_string($resp);
             if (false !== $respObject) {
                 return json_decode(json_encode($respObject), true);
             }
         }
     }
     return ['errcode' => 90000, 'errmsg' => 'HTTP_RESPONSE_NOT_WELL_FORMED'];
 }
コード例 #2
0
ファイル: ESms.php プロジェクト: noikiy/wowewe
 public function submit($url, $params)
 {
     try {
         $requestUrl = $url . '?';
         if ($this->method == 'GET') {
             $requestUrl .= http_build_query($params);
             $postFields = null;
         } else {
             $postFields = $params;
         }
         if ($this->debug) {
             U::W(array($requestUrl, $postFields));
             $this->resp_code = ESms::OK_CURL;
             return;
         }
         //U::W(array($requestUrl, $postFields));
         $resp = U::curl($requestUrl, $postFields);
         if ($this->message_is_gbk) {
             $resp = iconv("GBK", "UTF-8//IGNORE", $resp);
         }
         //U::W($resp);
     } catch (Exception $e) {
         U::W(array(__FUNCTION__, get_class($this), 'ERROR_CURL', $url, $params));
         $this->resp_code = ESms::ERROR_CURL;
         $this->resp = $e->getCode() . ',' . $e->getMessage();
         return;
     }
     $respWellFormed = false;
     if ("json" == $this->format) {
         $respObject = json_decode($resp);
         if (null !== $respObject) {
             $respWellFormed = true;
         }
     } else {
         if ("xml" == $this->format) {
             //$respObject = @simplexml_load_string($resp);
             $respObject = @simplexml_load_string(trim($resp));
             if (false !== $respObject) {
                 $respWellFormed = true;
                 $respObject = json_decode(json_encode($respObject));
             }
         } else {
             $respWellFormed = true;
             $respObject = $resp;
         }
     }
     if (false === $respWellFormed) {
         U::W(array(__FUNCTION__, get_class($this), 'HTTP_RESPONSE_NOT_WELL_FORMED', $resp, $url, $params));
         $this->resp_code = ESms::ERROR_HTTP_RESPONSE_NOT_WELL_FORMED;
         $this->resp = 'HTTP_RESPONSE_NOT_WELL_FORMED';
         return;
     }
     $this->resp_code = ESms::OK_CURL;
     $this->resp = $respObject;
     //U::W($this->resp);
 }
コード例 #3
0
ファイル: CmdController.php プロジェクト: noikiy/wowewe
 public function actionShowMobileInfo($id = null)
 {
     $postFields = null;
     $appkey = '5d4a589b32d70ad6378c8c69cba63524';
     //$appkey = ' -H apikey:3d9a61582849efccd65f77f34db064a8';
     $mobilenumber = '15071087608';
     $requestUrl = 'http://apis.juhe.cn/mobile/get?phone=' . $mobilenumber . '&key=' . $appkey;
     //$requestUrl = 'http://appyun.sinaapp.com/index.php?app=mobile&controller=index&action=api&outfmt=json&mobile='.$mobilenumber;
     try {
         //U::W($requestUrl);
         $resp = U::curl($requestUrl, $postFields);
         //U::W($resp);
     } catch (Exception $e) {
         U::W($e->getCode() . ':' . $e->getMessage());
         return ['errcode' => $e->getCode(), 'errmsg' => $e->getMessage()];
     }
     $arr = json_decode($resp, true);
     if (null !== $arr) {
         U::W("--------------actionShowMobileInfo----------------");
         U::W($arr);
         //return $arr;
     }
 }
コード例 #4
0
ファイル: Wechat.php プロジェクト: noikiy/wowewe
 public static function WxApi($gatewayUrl, $sysParams = [], $postFields = null, $format = 'json')
 {
     $requestUrl = $gatewayUrl . "?";
     foreach ($sysParams as $sysParamKey => $sysParamValue) {
         $requestUrl .= "{$sysParamKey}=" . urlencode($sysParamValue) . "&";
     }
     $requestUrl = substr($requestUrl, 0, -1);
     try {
         //U::W($requestUrl);
         $resp = U::curl($requestUrl, $postFields);
         //U::W($resp);
     } catch (Exception $e) {
         U::W($e->getCode() . ':' . $e->getMessage());
         return ['errcode' => $e->getCode(), 'errmsg' => $e->getMessage()];
     }
     if ("json" === $format) {
         $arr = json_decode($resp, true);
         if (null !== $arr) {
             return $arr;
         }
     } else {
         if ("xml" === $format) {
             $respObject = @simplexml_load_string($resp);
             if (false !== $respObject) {
                 return json_decode(json_encode($respObject), true);
             }
         }
     }
     U::W($resp);
     return ['errcode' => 90000, 'errmsg' => 'HTTP_RESPONSE_NOT_WELL_FORMED'];
 }