Пример #1
0
#!/usr/bin/env php
<?php 
require 'db.php';
require 'queue.php';
require 'curl.php';
$db = new DB();
const GOOGLE_SEARCH = 'https://ajax.googleapis.com/ajax/services/search/web?';
const QUEUE_LIMIT = 20;
$curl = new CURL();
foreach ($db->queues(STATUS_NEW, QUEUE_LIMIT) as $queue) {
    $url = GOOGLE_SEARCH . http_build_query(['v' => '1.0', 'q' => $queue['word']]);
    $curl->execute($url);
    if ($curl->isHttpOK()) {
        //    var_dump($curl->getContent());
        $db->queue_data($queue['id'], $curl->getContent());
    } else {
        $db->queue_error($queue['id'], $curl->getErrorMessage());
    }
}