hackerone / curl
此包最新版本(dev-master)没有可用的许可信息。
Curl Wrapper for PHP
dev-master
2014-11-14 14:27 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-23 13:42:02 UTC
README
更新
- 现在也可以用于非Yii应用程序。(如果你使用Yii,它仍然可以作为组件使用)
- 懒加载curl。
-
- getHeader方法
要求
- PHP 5.3+
- Yii 1.1.7(也应该适用于较旧版本)
- Curl和php-curl已安装
设置说明
- 将Curl.php或git clone放入你的项目protected/extensions/curl文件夹中
- 在main.php或console.php中,将以下内容添加到'components'
'curl' => array( 'class' => 'ext.curl.Curl', 'options' => array(/* additional curl options */), ),
用法
- 使用默认参数GET页面
$output = Yii::app()->curl->get($url, $params); // output will contain the result of the query // $params - query that'll be appended to the url
- 向页面POST数据
$output = Yii::app()->curl->post($url, $data); // $data - data that will be POSTed
- PUT数据
$output = Yii::app()->curl->put($url, $data, $params); // $data - data that will be sent in the body of the PUT
- PATCH数据
$output = Yii::app()->curl->patch($url, $data); // $data - data that will be PATCHed
- DELETE
$output = Yii::app()->curl->delete($url, $params); // $params - query that'll be appended to the url
- 在GET或POST之前设置选项
$output = Yii::app()->curl->setOption($name, $value)->get($url, $params); // $name & $value - CURL options $output = Yii::app()->curl->setOptions(array($name => $value))->get($get, $params); // pass key value pairs containing the CURL options