curlphp / httpcurl
用于服务器端请求的PHP cURL库。
1.0.2
2016-04-09 00:00 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-26 00:31:57 UTC
README
cURL-PHP是一个PHP库,它使简单的cURL请求变得容易,同时使复杂的cURL请求也变得更加简单。
要求
- PHP 5.4+
- PHP 5(已启用cURL配置)
- libcurl
特性
- 通过HTTP进行POST/GET/PATCH/PUT/DELETE请求
- HTTP认证
- 遵循重定向
- 返回错误字符串
- 提供调试信息
- 代理支持
- Cookie
API调用
这些调用可以在一行代码中完成,使生活变得简单。它们返回页面主体,或者在失败时返回FALSE。
API对象方法调用的层次结构可能会影响功能部分。
这些方法允许您构建更复杂的请求。
// import file
require 'curlphp/curlphp.php'
// Create an object
$curl = new curlphp();
// Option
$curl->setOption(CURLOPT_BUFFERSIZE, 10);
$curl->setOption(array(CURLOPT_BUFFERSIZE => 10));
// More human looking options
$curl->setOption('buffersize', 10);
// Headers
$curl->http_header('Content-Type','application/json');
$curl->http_header('Content-Length',300);
// SSL Option
$curl->setSSL(false);
// Login to HTTP user authentication
$curl->http_login('username', 'password');
// Cookies - If you do not use post, it will just run a GET request
$vars = array('foo'=>'bar');
$curl->set_cookies($vars);
// Proxy - Request the page through a proxy server
// Port is optional, defaults to 80
$curl->proxy('http://example.com', 1080);
$curl->proxy('http://example.com');
// Proxy login
$curl->proxy_login('username', 'password');
// Execute - returns responce
echo $curl->executeCurl();
// Debug data ------------------------------------------------
$curl->debug();
// Errors
$curl->error_code; // int
$curl->error_string;
// Information
$curl->info; // array