diff --git a/core/curl.lib.php b/core/curl.lib.php index 7e69355..d11b004 100644 --- a/core/curl.lib.php +++ b/core/curl.lib.php @@ -10,7 +10,7 @@ namespace LaneWeChat\Core; * @Date: 14-1-10 * @Time: 下午4:22 * Mail: lixuan868686@163.com - * Website: http://www.lanecn.com + * Website: http://www.lanecn.com */ class Curl { @@ -30,6 +30,8 @@ class Curl * @param string $queryUrl 请求的URL * @param array|string $param 参数 * @param string $method 请求方法,默认为'get' + * @param bool $is_json 是否将返回结果解析为JSON,默认为true + * @param bool $is_urlcode 是否对POST参数进行URL编码,默认为true * @return bool|mixed 返回请求结果或false */ public static function callWebServer($queryUrl, $param = '', $method = 'get', $is_json = true, $is_urlcode = true) @@ -216,4 +218,15 @@ class Curl } return $response; } -} \ No newline at end of file +} +类声明:class Curl 定义了一个名为 Curl 的类,用于简化HTTP请求操作。 +私有静态变量:private static $_ch; 等变量用于存储CURL会话句柄、头部、主体等信息。 +存储数组:private static $_cookie = array(); 等数组用于存储Cookie、选项、URL和Referer等信息。 +callWebServer方法:用于调用外部URL,支持GET和POST请求。根据请求方法调用相应的私有方法,并根据参数决定是否解析为JSON。 +_init方法:初始化CURL会话,设置CURL选项。 +setOption方法:设置CURL选项,传入选项数组。 +_close方法:关闭CURL会话。 +_httpGet方法:发送GET请求,构建查询字符串并设置CURL选项。 +_httpPost方法:发送POST请求,对参数进行URL编码并设置CURL选项。 +_put、_delete、_head方法:分别用于发送PUT、DELETE和HEAD请求,设置相应的CURL选项。 +_execute方法:执行CURL请求,如果发生错误则抛出异常。 \ No newline at end of file