コード例 #1
0
<?php

define('DEBUG', 'on');
define('WEBPATH', realpath(__DIR__ . '/..'));
//包含框架入口文件
require WEBPATH . '/libs/lib_config.php';
function test(Swoole\Async\HttpClient $class, $body, $header)
{
    echo $class->id . " finish\n";
    //var_dump($header);
    $class->close();
}
for ($i = 0; $i < 10; $i++) {
    $httpclient = new \Swoole\Async\HttpClient("http://news.163.com/15/0122/13/AGILC6J90001124J.html");
    $httpclient->id = $i;
    $httpclient->onReady("test");
    $httpclient->get();
}
コード例 #2
0
ファイル: http_client.php プロジェクト: jasonshaw/framework-1
<?php

define('DEBUG', 'on');
define('WEBPATH', dirname(__DIR__));
require WEBPATH . '/libs/lib_config.php';
$client = new Swoole\Async\HttpClient('http://127.0.0.1:8888/post.php');
$client->onReady(function ($cli, $body, $header) {
    var_dump($body, $header);
});
$client->post(array('hello' => 'world'));
$client = new Swoole\Async\HttpClient('http://www.baidu.com/');
$client->onReady(function ($cli, $body, $header) {
    var_dump($body, $header);
});
$client->get();