# PHP Curl Class: HTTP requests made easy
[![](https://img.shields.io/github/release/php-curl-class/php-curl-class.svg)](https://github.com/php-curl-class/php-curl-class/releases/)
[![](https://img.shields.io/github/license/php-curl-class/php-curl-class.svg)](https://github.com/php-curl-class/php-curl-class/blob/master/LICENSE)
[![](https://img.shields.io/travis/php-curl-class/php-curl-class.svg)](https://travis-ci.org/php-curl-class/php-curl-class/)
[![](https://img.shields.io/packagist/dt/php-curl-class/php-curl-class.svg)](https://github.com/php-curl-class/php-curl-class/releases/)
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.
![PHP Curl Class screencast](www/img/screencast.gif)
---
- [Installation](#installation)
- [Requirements](#requirements)
- [Quick Start and Examples](#quick-start-and-examples)
- [Available Methods](#available-methods)
- [Security](#security)
- [Troubleshooting](#troubleshooting)
- [Run Tests](#run-tests)
- [Contribute](#contribute)
---
### Installation
To install PHP Curl Class, simply:
$ composer require php-curl-class/php-curl-class
For latest commit version:
$ composer require php-curl-class/php-curl-class @dev
### Requirements
PHP Curl Class works with PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, and HHVM.
### Quick Start and Examples
More examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples).
```php
require __DIR__ . '/vendor/autoload.php';
use \Curl\Curl;
$curl = new Curl();
$curl->get('https://www.example.com/');
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
} else {
echo 'Response:' . "\n";
var_dump($curl->response);
}
```
```php
// https://www.example.com/search?q=keyword
$curl = new Curl();
$curl->get('https://www.example.com/search', array(
'q' => 'keyword',
));
```
```php
$curl = new Curl();
$curl->post('https://www.example.com/login/', array(
'username' => 'myusername',
'password' => 'mypassword',
));
```
```php
$curl = new Curl();
$curl->setBasicAuthentication('username', 'password');
$curl->setUserAgent('MyUserAgent/0.0.1 (+https://www.example.com/bot.html)');
$curl->setReferrer('https://www.example.com/url?url=https%3A%2F%2Fwww.example.com%2F');
$curl->setHeader('X-Requested-With', 'XMLHttpRequest');
$curl->setCookie('key', 'value');
$curl->get('https://www.example.com/');
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
} else {
echo 'Response:' . "\n";
var_dump($curl->response);
}
var_dump($curl->requestHeaders);
var_dump($curl->responseHeaders);
```
```php
$curl = new Curl();
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
$curl->get('https://shortn.example.com/bHbVsP');
```
```php
$curl = new Curl();
$curl->put('https://api.example.com/user/', array(
'first_name' => 'Zach',
'last_name' => 'Borboa',
));
```
```php
$curl = new Curl();
$curl->patch('https://api.example.com/profile/', array(
'image' => '@path/to/file.jpg',
));
```
```php
$curl = new Curl();
$curl->patch('https://api.example.com/profile/', array(
'image' => new CURLFile('path/to/file.jpg'),
));
```
```php
$curl = new Curl();
$curl->delete('https://api.example.com/user/', array(
'id' => '1234',
));
```
```php
// Enable all supported encoding types and download a file.
$curl = new Curl();
$curl->setOpt(CURLOPT_ENCODING , '');
$curl->download('https://www.example.com/file.bin', '/tmp/myfile.bin');
```
```php
// Case-insensitive access to headers.
$curl = new Curl();
$curl->download('https://www.example.com/image.png', '/tmp/myimage.png');
echo $curl->responseHeaders['Content-Type'] . "\n"; // image/png
echo $curl->responseHeaders['CoNTeNT-TyPE'] . "\n"; // image/png
```
```php
// Clean up.
$curl->close();
```
```php
// Example access to curl object.
curl_set_opt($curl->curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1');
curl_close($curl->curl);
```
```php
require __DIR__ . '/vendor/autoload.php';
use \Curl\MultiCurl;
// Requests in parallel with callback functions.
$multi_curl = new MultiCurl();
$multi_curl->success(function($instance) {
echo 'call to "' . $instance->url . '" was successful.' . "\n";
echo 'response:' . "\n";
var_dump($instance->response);
});
$multi_curl->error(function($instance) {
echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
echo 'error code: ' . $instance->errorCode . "\n";
echo 'error message: ' . $instance->errorMessage . "\n";
});
$multi_curl->complete(function($instance) {
echo 'call completed' . "\n";
});
$multi_curl->addGet('https://www.google.com/search', array(
'q' => 'hello world',
));
$multi_curl->addGet('https://duckduckgo.com/', array(
'q' => 'hello world',
));
$multi_curl->addGet('https://www.bing.com/search', array(
'q' => 'hello world',
));
$multi_curl->start(); // Blocks until all items in the queue have been processed.
```
More examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples).
### Available Methods
```php
Curl::__construct($base_url = null)
Curl::__destruct()
Curl::__get($name)
Curl::attemptRetry()
Curl::beforeSend($callback)
Curl::buildPostData($data)
Curl::call()
Curl::close()
Curl::complete($callback)
Curl::delete($url, $query_parameters = array(), $data = array())
Curl::download($url, $mixed_filename)
Curl::error($callback)
Curl::exec($ch = null)
Curl::execDone()
Curl::get($url, $data = array())
Curl::getCookie($key)
Curl::getInfo($opt = null)
Curl::getOpt($option)
Curl::getResponseCookie($key)
Curl::getResponseCookies()
Curl::head($url, $data = array())
Curl::options($url, $data = array())
Curl::patch($url, $data = array())
Curl::post($url, $data = array(), $follow_303_with_post = false)
Curl::progress($callback)
Curl::put($url, $data = array())
Curl::removeHeader($key)
Curl::search($url, $data = array())
Curl::setBasicAuthentication($username, $password = '')
Curl::setConnectTimeout($seconds)
Curl::setCookie($key, $value)
Curl::setCookieFile($cookie_file)
Curl::setCookieJar($cookie_jar)
Curl::setCookieString($string)
Curl::setCookies($cookies)
Curl::setDefaultDecoder($mixed = 'json')
Curl::setDefaultJsonDecoder()
Curl::setDefaultTimeout()
Curl::setDefaultUserAgent()
Curl::setDefaultXmlDecoder()
Curl::setDigestAuthentication($username, $password = '')
Curl::setHeader($key, $value)
Curl::setHeaders($headers)
Curl::setJsonDecoder($mixed)
Curl::setMaxFilesize($bytes)
Curl::setOpt($option, $value)
Curl::setOpts($options)
Curl::setPort($port)
Curl::setReferer($referer)
Curl::setReferrer($referrer)
Curl::setRetry($mixed)
Curl::setTimeout($seconds)
Curl::setUrl($url, $mixed_data = '')
Curl::setUserAgent($user_agent)
Curl::setXmlDecoder($mixed)
Curl::success($callback)
Curl::unsetHeader($key)
Curl::verbose($on = true, $output = STDERR)
MultiCurl::__construct($base_url = null)
MultiCurl::__destruct()
MultiCurl::addCurl(Curl $curl)
MultiCurl::addDelete($url, $query_parameters = array(), $data = array())
MultiCurl::addDownload($url, $mixed_filename)
MultiCurl::addGet($url, $data = array())
MultiCurl::addHead($url, $data = array())
MultiCurl::addOptions($url, $data = array())
MultiCurl::addPatch($url, $data = array())
MultiCurl::addPost($url, $data = array(), $follow_303_with_post = false)
MultiCurl::addPut($url, $data = array())
MultiCurl::addSearch($url, $data = array())
MultiCurl::beforeSend($callback)
MultiCurl::close()
MultiCurl::complete($callback)
MultiCurl::error($callback)
MultiCurl::getOpt($option)
MultiCurl::removeHeader($key)
MultiCurl::setBasicAuthentication($username, $password = '')
MultiCurl::setConcurrency($concurrency)
MultiCurl::setConnectTimeout($seconds)
MultiCurl::setCookie($key, $value)
MultiCurl::setCookieFile($cookie_file)
MultiCurl::setCookieJar($cookie_jar)
MultiCurl::setCookieString($string)
MultiCurl::setCookies($cookies)
MultiCurl::setDigestAuthentication($username, $passw
没有合适的资源?快使用搜索试试~ 我知道了~
智云影院PHP源码V3.6.6.2缓存版.zip_b y 8 8 7 3.com_site:www.pudn.com_www.
共369个文件
php:139个
js:56个
png:56个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 40 浏览量
2022-09-21
22:47:40
上传
评论
收藏 3.99MB ZIP 举报
温馨提示
第一次使用本源码请到后台登录设置,点击恢复更新缓存! 或者是自行恢复更新缓存文件(首页如;你的域名/index.php,电影,电视剧,综艺,动漫都是一样) 源码使用说明; 本源码可直接上传,无需安装数据库,源码上传就可以使用!上传可登录后台设置,修改你的相关信息保存即可!本源码支持上传二级目录访问 提示:若首页更新修改或者是更新源码请在空间服务器删除缓存文件index.html即可 4、后台登陆:http://你的域名/admin/ 默认账号和密码:admin
资源详情
资源评论
资源推荐
收起资源包目录
智云影院PHP源码V3.6.6.2缓存版.zip_b
y
8
8
7
3.com_site:www.pudn.com_www. (369个子文件)
bootstrap.css 145KB
bootstrap.min.css 125KB
bootstrap.min.css 118KB
style.css 58KB
style.css 47KB
css.css 30KB
style.css 29KB
style.min.css 28KB
index.css 25KB
global.css 22KB
swiper.min.css 18KB
share.css 16KB
public.css 12KB
index.css 12KB
home.css 11KB
home.css 11KB
movie.css 10KB
dongman.css 10KB
tv.css 10KB
download.css 9KB
wallpaper.css 8KB
seacher.css 7KB
yhq.css 6KB
yy.css 6KB
color.css 6KB
404.css 5KB
gaoxiao.css 5KB
theme.css 5KB
CSS3style.css 4KB
cili.css 4KB
woaik.css 4KB
down.css 4KB
style.css 4KB
play.css 3KB
pucms.css 3KB
iconfont.css 2KB
onepage-scroll.css 2KB
sty.css 1KB
bfq.css 571B
sylebj.css 0B
.editorconfig 139B
fontawesome-webfont.eotfontawesome-webfont.eot 162KB
iconfont.eot 19KB
icomoon.eot 1KB
glyphicons-halflings-regular.eot 481B
glyphicons-halflings-regular.eot 481B
load.gif 64KB
dc5c7986daef50c.gif 26KB
loading.gif 10KB
loading388.gif 10KB
digg_art.gif 6KB
digg_art.gif 6KB
load.gif 6KB
lazy.gif 4KB
pload.gif 2KB
digg_art_bg.gif 2KB
digg_art_bg.gif 2KB
qq_login.gif 2KB
qq_login.gif 2KB
starrating.gif 2KB
starrating.gif 2KB
bg.gif 1KB
digg_vod.gif 947B
digg_vod.gif 947B
loading.gif 481B
loading.gif 481B
input.gif 65B
input.gif 65B
.gitignore 128B
dh.html 12KB
cx.html 6KB
indexs.html 5KB
tq.html 4KB
indexs.html 4KB
info.html 3KB
app.html 3KB
info.html 3KB
list.html 1KB
search.html 1KB
search.html 1KB
list.html 1KB
favicon.ico 9KB
3.jpg 934KB
t01ed2d8781d4a1a469.jpg 123KB
aly.jpg 74KB
top.jpg 12KB
nopic.jpg 3KB
sfz.js 270KB
view-history.js 206KB
id.js 126KB
thunderbatch.js 99KB
down.js 95KB
swiper.min.js 94KB
jquery.min.js 94KB
jquery.min.js 93KB
jquery-1.7.2.min.js 93KB
jquery.js 93KB
jquery-1.9.1.min.js 90KB
m.js 85KB
jquery.min.js 85KB
共 369 条
- 1
- 2
- 3
- 4
APei
- 粉丝: 81
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0