From 1bfce61dd56b0fa33295018e6d53286b9d892b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=96=8C?= Date: Fri, 15 Jul 2016 12:46:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E8=AF=95=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TimRestApi.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/TimRestApi.php b/TimRestApi.php index 1bc3ce8..30fb349 100644 --- a/TimRestApi.php +++ b/TimRestApi.php @@ -15,17 +15,25 @@ class TimRestAPI extends TimRestInterface protected $contenttype = 'json'; protected $apn = '0'; + /** + * 是否开启调试模式 + * @var bool + */ + protected $debug = true; + /** * 初始化函数 * @param int $sdkappid 应用的appid * @param string $identifier 访问接口的用户 + * @param bool $debug 是否开启调试模式(默认不开启) */ - function init($sdkappid, $identifier) + function init($sdkappid, $identifier, $debug = false) { $this->sdkappid = $sdkappid; $this->identifier = $identifier; + $this->debug = $debug; } /** @@ -48,8 +56,11 @@ public function api($service_name, $cmd_name, $identifier, $usersig, $req_data, . "&sdkappid=" . $this->sdkappid . "&contenttype=" . $this->contenttype; $url = $this->http_type . $this->im_yun_url . '/' . $this->version . '/' . $service_name . '/' .$cmd_name . '?' . $parameter; - - if($print_flag) + + /** + * 如果开启了调试模式,打印请求和响应的相应信息 + */ + if($this->debug) { echo "Request Url:\n"; echo $url;