Пример #1
0
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;
}
Пример #2
0
 /**
  * @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;
     }
 }
Пример #3
0
 protected function _makeRequest()
 {
     $bot = new Bot($this->_links);
     $bot->execute();
     $docs = $bot->getDocuments();
     return $docs;
 }