Permalink
Browse files

now fetching rss xml using curl, which is mor commonly available than…

… simplexml loading remote url
  • Loading branch information...
erik
erik committed Nov 17, 2009
1 parent 1a21137 commit dd8f66b334229eebabdf76b3063ce6f5240d3b34
Showing with 26 additions and 5 deletions.
  1. +9 −2 basic.php
  2. +9 −2 entertainment.php
  3. +8 −1 standard.php
View
@@ -9,8 +9,15 @@
//sample url
$feedUrl = 'http://public.yahoo.com/~jchu/basic_feed_structure.xml';
+//fetch rss xml in a commonly available way
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, $feedUrl);
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+$xmlString = curl_exec($ch);
+curl_close($ch);
+
//parse xml
-$feed = simplexml_load_file($feedUrl);
+$feed = simplexml_load_string($xmlString);
//format data & set default values to keep template uncluttered
$data = array(
@@ -239,4 +246,4 @@
</li>
<? endforeach ?>
</ul>
-</div>
+</div>
View
@@ -9,8 +9,15 @@
//config
$feedUrl = 'http://public.yahoo.com/~jchu/entertainment_feed_structure.xml';
+//fetch rss xml in a commonly available way
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, $feedUrl);
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+$xmlString = curl_exec($ch);
+curl_close($ch);
+
//parse xml
-$feed = simplexml_load_file($feedUrl);
+$feed = simplexml_load_string($xmlString);
//format data & set default values to keep template uncluttered
$data = array(
@@ -280,4 +287,4 @@
</div>
<div style="clear:both"></div>
</div>
-</div>
+</div>
View
@@ -6,8 +6,15 @@
$feedUrl = 'http://rss.news.yahoo.com/rss/world';
+//fetch rss xml in a commonly available way
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, $feedUrl);
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+$xmlString = curl_exec($ch);
+curl_close($ch);
+
//parse xml
-$feed = simplexml_load_file($feedUrl);
+$feed = simplexml_load_string($xmlString);
//format data & set default values to keep template uncluttered
$data = array(

0 comments on commit dd8f66b

Please sign in to comment.