Esempio n. 1
0
function download($url)
{
    if ((bool) Config\get('debug_mode')) {
        Logger::enable();
    }
    $client = Client::getInstance();
    $client->setUserAgent(Config\HTTP_USER_AGENT);
    $client->enablePassthroughMode();
    $client->execute($url);
    Config\write_debug();
}
Esempio n. 2
0
function api_call($url)
{
    try {
        $client = Client::getInstance();
        $client->setUserAgent(Config\HTTP_USER_AGENT);
        $client->execute($url);
        return $client;
    } catch (ClientException $e) {
        return false;
    }
}
Esempio n. 3
0
 /**
  * Download and check if a resource exists.
  *
  * @param string $url URL
  *
  * @return \PicoFeed\Client Client instance
  */
 public function download($url)
 {
     $client = Client::getInstance();
     $client->setConfig($this->config);
     Logger::setMessage(get_called_class() . ' Download => ' . $url);
     try {
         $client->execute($url);
     } catch (ClientException $e) {
         Logger::setMessage(get_called_class() . ' Download Failed => ' . $e->getMessage());
     }
     return $client;
 }
Esempio n. 4
0
 /**
  * @group online
  */
 public function testContentType()
 {
     $client = Client::getInstance();
     $client->setUrl('http://miniflux.net/assets/img/favicon.png');
     $client->execute();
     $this->assertEquals('image/png', $client->getContentType());
     $client = Client::getInstance();
     $client->setUrl('http://miniflux.net/');
     $client->execute();
     $this->assertEquals('text/html; charset=utf-8', $client->getContentType());
 }
Esempio n. 5
0
 /**
  * Download a feed (no discovery)
  *
  * @access public
  * @param  string            $url              Feed url
  * @param  string            $last_modified    Last modified HTTP header
  * @param  string            $etag             Etag HTTP header
  * @return \PicoFeed\Client\Client
  */
 public function download($url, $last_modified = '', $etag = '')
 {
     $url = $this->prependScheme($url);
     return Client::getInstance()->setConfig($this->config)->setLastModified($last_modified)->setEtag($etag)->execute($url);
 }
Esempio n. 6
0
 /**
  * Download the HTML content.
  *
  * @return bool
  */
 public function download()
 {
     if (!empty($this->url)) {
         // Clear everything
         $this->html = '';
         $this->content = '';
         $this->encoding = '';
         try {
             $client = Client::getInstance();
             $client->setConfig($this->config);
             $client->setTimeout($this->config->getGrabberTimeout());
             $client->setUserAgent($this->config->getGrabberUserAgent());
             $client->execute($this->url);
             $this->url = $client->getUrl();
             $this->html = $client->getContent();
             $this->encoding = $client->getEncoding();
             return true;
         } catch (ClientException $e) {
             Logger::setMessage(get_called_class() . ': ' . $e->getMessage());
         }
     }
     return false;
 }
Esempio n. 7
0
 /**
  * Download the HTML content
  *
  * @access public
  * @return HTML content
  */
 public function download()
 {
     if (!$this->skip_processing && $this->url != '') {
         try {
             $client = Client::getInstance();
             $client->setConfig($this->config);
             $client->execute($this->url);
             $this->url = $client->getUrl();
             $this->html = $client->getContent();
             $this->encoding = $client->getEncoding();
         } catch (ClientException $e) {
             Logger::setMessage(get_called_class() . ': ' . $e->getMessage());
         }
     }
     return $this->html;
 }
Esempio n. 8
0
 /**
  * Returns a new instance of an PicoFeed Http client
  * @return \PicoFeed\Client instance
  */
 public function build()
 {
     $client = Client::getInstance();
     $client->setConfig($this->config);
     return $client;
 }