function execute_request($key, $url) { $urls = array("{$key}" => $url); $bot = new Bot($urls); $bot->execute(); $document = array_pop($bot->getDocuments()); if ($document) { return $document->getHttpResponse()->getBody(); } return false; }
/** * @param array $opts Array of options containing array of urls to be executed * whether or not response in json is required */ protected static function _execute($opts) { $bot = new Bot($opts['urls']); $bot->execute(); $documents = $bot->getDocuments(); $count = count($opts['urls']); if ($count == 1) { $doc = array_shift($documents); $body = $doc->getHttpResponse()->getBody(); return $opts['json'] ? json_decode($body) : $body; } elseif ($count > 1) { $return = array(); foreach ($documents as $doc) { $return[$doc->uri] = $doc->getHttpResponse->getBody(); } return $return; } }
<?php namespace WebBot\lib\WebBot; use WebBot\lib\WebBot\Bot; // set unlimited execution time set_time_limit(0); // set the default timeout to 1 seconds Bot::$conf_default_timeout = 1; // set delay between consecutive fetches (in milli seconds) Bot::$conf_delay_between_fetches = 1000; // do not use HTTPS protocol Bot::$conf_force_https = false; // don't include document field raw values Bot::$conf_include_document_field_raw_values = false; // set the directory for storing information // $dir = your/custom/path; $dir = LIB_PATH . '/WebBot/tmp/'; Bot::$conf_store_dir = $dir;
protected function _makeRequest() { $bot = new Bot($this->_links); $bot->execute(); $docs = $bot->getDocuments(); return $docs; }