示例#1
0
 protected function createReq()
 {
     $req = new Client();
     $req->setMaxRequest(10);
     return $req;
 }
           [id] => http://google.com
           [shares] => 9623503
           [comments] => 10117
           [time] => 0.575178
       )
)
execution time: 0.587344
execution time sum: 1.882179
all comments: 11468
*/
include __DIR__ . '/../vendor/autoload.php';
use MCurl\Client;
$sites = array('google.com', 'yandex.ru', 'facebook.com', 'mail.ru');
$results = array();
$all_comments = 0;
$client = new Client();
foreach ($sites as $site) {
    $client->add(array(CURLOPT_URL => 'https://graph.facebook.com/http://' . $site));
}
$time = microtime(true);
$all_time = 0;
while ($result = $client->next()) {
    $info = $result->json;
    $all_time += $info->time = $result->info['total_time'];
    if (!empty($info->comments)) {
        $all_comments += $info->comments;
    }
    $results[] = $info;
}
$time -= microtime(true);
$time *= -1;