当前位置: 首页>>代码示例>>PHP>>正文


PHP Curl::setJsonDecoder方法代码示例

本文整理汇总了PHP中Curl\Curl::setJsonDecoder方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::setJsonDecoder方法的具体用法?PHP Curl::setJsonDecoder怎么用?PHP Curl::setJsonDecoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Curl\Curl的用法示例。


在下文中一共展示了Curl::setJsonDecoder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public static function run($method, $params = [])
 {
     self::$defaultParam = ['method' => $method, 'module' => 'API', 'token_auth' => STAT_API_TOKEN, 'format' => 'JSON', 'expanded ' => true, 'idSite' => 1, 'filter_offset' => \yii::$app->request->get('filter_offset', 0), 'filter_limit' => \yii::$app->request->get('filter_limit', 50)];
     $params['formatDate'] = isset($params['formatDate']) ? $params['formatDate'] : null;
     if ($params['formatDate'] !== false) {
         self::formatDate();
     }
     unset($params['formatDate']);
     $params = array_merge(self::$defaultParam, $params);
     $params = array_filter($params);
     $curl = new Curl();
     $curl->setJsonDecoder(function ($response) {
         $json_obj = json_decode($response, true);
         if (!($json_obj === null)) {
             $response = $json_obj;
         }
         return $response;
     });
     $curl->get(STAT_API_URL, $params);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:26,代码来源:API.php

示例2: __construct

 public function __construct($iniFile)
 {
     $this->loadBaseMods();
     $this->loadIni($iniFile);
     $this->pdo = new lw\Pdo($this, $this->configArray['Pdo']);
     $this->curl = new \Curl\Curl();
     //Set this option because WAMP sucks
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     //Set this because all the returns are expecting JSON string, and Curl updated to do it automatically.
     $this->curl->setJsonDecoder(function ($response) {
         return $response;
     });
     $this->url = $this->configArray['Site']['url'];
     $this->title = $this->configArray['Site']['title'];
     Core::setApiKey($this->configArray['Site']['APIKEY']);
 }
开发者ID:jlawrence11,项目名称:wowApi,代码行数:16,代码来源:FactoryLw.php

示例3: run

 public function run($params)
 {
     $params = array_merge(self::$default, $params);
     $curl = new Curl();
     $curl->setJsonDecoder(function ($response) {
         $json_obj = json_decode($response, true);
         if (!($json_obj === null)) {
             $response = $json_obj;
         }
         return $response;
     });
     $curl->get(self::STAT_API_URL, $params);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:19,代码来源:BaseApi.php

示例4: get

 public static function get($users, $type, $ref)
 {
     $url = 'http://' . self::$referrerType[$ref] . '.gallary.work/api/user/GetUserData';
     $params = ['userName' => $users, 'userDataType' => $type, 'signKey' => self::SIGN_KEY, 'lastLoginStartTime' => '', 'lastLoginEndTime' => '', 'datatype' => 'json'];
     $curl = new Curl();
     $curl->setJsonDecoder(function ($response) {
         $json_obj = json_decode($response, true);
         if (!($json_obj === null)) {
             $response = $json_obj;
         }
         return $response;
     });
     $curl->get($url, $params);
     $curl->setConnectTimeout(10);
     $curl->close();
     if ($curl->error) {
         return false;
     } else {
         if ($curl->response === false) {
             return false;
         }
         return $curl->response;
     }
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:24,代码来源:RegUser.php

示例5: placeDetails

 /**
  * Google Places API Web Service
  * Place Details
  *
  * @param string $placeId
  * @return array
  * @see https://developers.google.com/places/web-service/details
  */
 private function placeDetails($placeId)
 {
     $curl = new Curl();
     $curl->setTimeout(15);
     $curl->setOpt(CURLOPT_SSL_VERIFYHOST, false);
     $curl->setJsonDecoder(function ($string) {
         return json_decode($string, true);
     });
     $curl->get(Config::get('googleplaces.api_details'), ['key' => Config::get('googleplaces.key'), 'language' => 'zh-CN', 'placeid' => $placeId]);
     if ($curl->error) {
         return ['status' => $curl->errorMessage];
     } else {
         $response = $curl->response;
         foreach ($response['result']['address_components'] as $i => $item) {
             $response['result']['address_components'][$item['types'][0]] = $item;
             unset($response['result']['address_components'][$i]);
         }
         return $response;
     }
 }
开发者ID:popfeng,项目名称:zao,代码行数:28,代码来源:HereController.php


注:本文中的Curl\Curl::setJsonDecoder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。