# PHP class fetch_url **Repository Path**: zhanglei/php-class-fetch_url ## Basic Information - **Project Name**: PHP class fetch_url - **Description**: 由PHP扩展实现的远程访问类fetchurl,安装扩展前需要先安装libcurl - **Primary Language**: C - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2014-05-13 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 一、类文档说明 class FetchUrl{ function __construct(); /** * 返回网页内容 常用于fetch()方法返回false时 * @return string */ function body(); /** * 将对象的数据重新初始化,用于多次重用一个FetchUrl对象 * @return void */ function clean(); /** * 返回错误信息 * @return string */ function errmsg(); /** * 返回错误码,>0表示有错误 * @return int */ function errcode(); /** * 发起请求 * $url string 请求地址 * $callback function 匿名函数 */ function fetch(string $url, function $callback); /** * 请求返回HTTP Code * @return int */ function httpCode(); /** * 请求返回Cookies数组 * @return array */ function responseCookies(); /** * 请求返回头部信息数组 * @return array */ function responseHeaders(); /** * 是否允许截断,默认为不允许 * @param bool $allow=false */ function setAllowRedirect(bool $allow=false); /** * 设置连接超时时间 * @param int $seconds=5 */ function setConnectTimeout(int $seconds=5); /** * 在发起的请求中,添加cookie数据 * @param string $name cookie键名 * @param string $value cookie值 */ function setCookie(string $name, string $value); /** * 在发起的请求中,批量添加cookie数据 * @param array $cookies */ function setCookies(array $cookies); /** * 设置请求的方法(POST/GET) * @param string $method="get" */ function setMethod(string $method="get"); /** * 设置POST方法的数据 * @param array $data */ function setPostData(array $data); /** * 设置读取超时时间 * @param int $seconds=60 */ function setReadTimeout(int $seconds=60); function __destroy(); }