How to convert feeds to html using javascript and php

Hi friends, in this post i am going to explain about how to convert feeds to html using javascript and php. Just provide feed url and get the list of entries and description from the feeds. In my previous post explained about steps to implement and hosting your website in google app engine for free.I have placed the Javascript code in google app engine hosted site.

How to convert feeds to html using javascript and php by Anil Kumar Panigrahi

How to convert feeds to html using javascript and php by Anil Kumar Panigrahi

demo link for how to convert feeds to html using javascript and php download link for how to convert feeds to html using javascript and php

 
Here i will explain how to get the entries with dynamic styles. In have created this post with using my previous posts.

1) How to get links from feed using php

http://www.anil2u.info/2009/12/how-to-get-links-from-feed-using-php/
 

2) How to clean a string using php code

http://www.anil2u.info/2010/02/how-to-clean-a-string-using-php-code/
 

3) How to create rss feeds using php and mysql

http://www.anil2u.info/2010/07/how-to-create-rss-feeds-using-php-and-mysql/
 

4)Examples for PHP Headers (301,302,404,…)

http://www.anil2u.info/2011/04/examples-for-php-headers-301302404/
 

5)how to include external js,css files with javascript

http://www.anil2u.info/2010/09/how-to-include-external-jscss-files-with-javascript/
 
In some servers DOMDocument(); is not working. For this we have to change the code like below
 

  <?php
       // initialize a new curl resource
       $ch = curl_init();
       // set the url to fetch
       curl_setopt($ch, CURLOPT_URL, $xml);
       // don't give me the headers just the content
       curl_setopt($ch, CURLOPT_HEADER, 0);
       // return the value instead of printing the response to browser
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       // use a user agent to mimic a browser
       curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
       $details = curl_exec($ch);
       // remember to always close the session and free all resources
       curl_close($ch);
  ?>

I have explained in the demo. Provide the feed url and font-size and get the javascript code. Place it in your html page.

 

Discussion 3 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>