peterfrench / yii2-curl
A Yii2 组件扩展用于 cURL。
1.0.5
2015-04-09 15:57 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-28 16:10:20 UTC
README
要求
- PHP 5.4+
- Yii 2.0.x
- Curl 和 php-curl 已安装
设置说明
安装此扩展的首选方式是通过 composer。
php composer.phar require --prefer-dist peterfrench/yii2-curl "*"
一旦 composer 安装了扩展,请在您的配置文件中包含该组件。
'curl' => [ 'class' => 'peterfrench\curl\Curl', 'options' => [ /* curl options */ ], ],
用法
- 使用默认参数获取页面
$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