php 卷曲类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
}
use \Curl\MultiCurl;
// Requests in parallel with callback functions.
$multiCurl = new MultiCurl();
$multiCurl->addGet('https://www.google.com/search', [
'q' => 'hello world',
]);
$multiCurl->success(function($instance) {
echo 'call to "' . $instance->url . '" was successful.' . "\n";
echo 'response:' . "\n";
var_dump($instance->response);
});
$multiCurl->error(function($instance) {
echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
echo 'error code: ' . $instance->errorCode . "\n";
echo 'error message: ' . $instance->errorMessage . "\n";
});
$multiCurl->complete(function($instance) {
echo 'call completed' . "\n";
});
$multiCurl->start();
以上是关于php 卷曲类的主要内容,如果未能解决你的问题,请参考以下文章
php 卷曲请求类(GET,POST)
php 卷曲类
markdown PHP卷曲类
处理大卷曲响应 - PHP
php 卷曲 - PHP认证
PHP PHP卷曲