X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=docs%2Fexamples%2FSimple_Feed_Aggregator.php;h=fd7ade47e17ce4b6ba4c9529d6441d5162bd4ec8;hp=f82e31675be71a89e28bf26122709617a1392bd7;hb=97e6c19380c21fd83b04fe9f4e30fa49e78a7159;hpb=6c4e793316be7f98f5400e24f498336db0d07af4 diff --git a/docs/examples/Simple_Feed_Aggregator.php b/docs/examples/Simple_Feed_Aggregator.php index f82e316..fd7ade4 100644 --- a/docs/examples/Simple_Feed_Aggregator.php +++ b/docs/examples/Simple_Feed_Aggregator.php @@ -30,8 +30,8 @@ class FeedAggregator public function addFeed($url) { $r = $this->setupRequest($url); - $r->send(); - $this->handleResponse($r); + $r->send(); + $this->handleResponse($r); } public function addFeeds($urls) @@ -65,11 +65,11 @@ class FeedAggregator protected function saveFeed($file, $contents) { - if (file_put_contents($this->directory .'/'. $file .'.xml', $contents)) { - $this->feeds[$file] = time(); - } else { - throw new Exception("Could not save feed contents to $file.xml"); - } + if (file_put_contents($this->directory .'/'. $file .'.xml', $contents)) { + $this->feeds[$file] = time(); + } else { + throw new Exception("Could not save feed contents to $file.xml"); + } } protected function loadFeed($file) @@ -87,8 +87,8 @@ class FeedAggregator protected function setupRequest($url) { - $r = new HttpRequest($url); - $r->setOptions(array('redirect' => true)); + $r = new HttpRequest($url); + $r->setOptions(array('redirect' => true)); $file = $this->url2name($url); @@ -102,14 +102,14 @@ class FeedAggregator protected function handleResponse(HttpRequest $r) { if ($r->getResponseCode() != 304) { - if ($r->getResponseCode() != 200) { - throw new Exception("Unexpected response code ". $r->getResponseCode()); - } - if (!strlen($body = $r->getResponseBody())) { - throw new Exception("Received empty feed from ". $r->getUrl()); - } - $this->saveFeed($file, $body); - } + if ($r->getResponseCode() != 200) { + throw new Exception("Unexpected response code ". $r->getResponseCode()); + } + if (!strlen($body = $r->getResponseBody())) { + throw new Exception("Received empty feed from ". $r->getUrl()); + } + $this->saveFeed($file, $body); + } } } ?>