This tutorial has moved back to Code Diaries.
You can view it there at Funky Twitter Thoughts Widget Using Yahoo and Twitter JSON APIs
How to generate content for facebook
12 years ago
Scripting tutorials, examples and snippets. javascript, web 2, ajax, php, perl. Learn how to create exciting widgets widgets using yahoo, google and wtitter apis and DOM. Harness the power of web 2.
1. /* scriptdiaries.blogspot.com 2. Righteous Ninja aka Ping Ching. 3. Free to use and modify.*/ 4. 5. google.load("feeds", "1"); 6. var YW_ContainerOk=false; 7. function YW_GetWeatherResults(result){ 8. if (!result.error){ 9. s="<table style=\"border-width:1px;border-collapse:collapse;border-style:solid; "+ 10. "border-color:#6D7B8D;width:1px;height:1px\" bgcolor=\"#ffffff\"><tbody><tr><td>"+ 11. result.feed.entries[0].content.match(/<img .*?>/)+"</td></tr></tbody></table>"; 12. document.getElementById("YW_weather_container").innerHTML="<b>"+result.feed.entries[0].title+ 13. "</b><br/>"+result.feed.entries[0].content.replace(/<img .*?>/,s); 14. } 15. } 16. function YW_CallWeather(hrf){ 17. if(!YW_ContainerOk){ 18. document.write("<div id=\"YW_weather_container\">There is no weather information available "+ 19. " for this location at this time</div>"); 20. YW_ContainerOk=true; 21. } 22. (new google.feeds.Feed(hrf)).load(YW_GetWeatherResults); 23. }Hide line numbers |
1. /* scriptdiaries.blogspot.com 2. Righteous Ninja aka Ping Ching. 3. Free to use and modify.*/ 4. 5. google.load("feeds", "1"); 6. var NWS_ContainerOk = false; 7. function NWS_GetNewsResults(result){ 8. if (!result.error){ 9. for(i=0;i<result.feed.entries.length;i++){ 10. tmprs = result.feed.entries[i]; 11. document.getElementById("gansyman").innerHTML+="<a href=\""+tmprs.link+"\">"+ 12. tmprs.title+"</a><br/>"+tmprs.content.substring(0,100)+"<br/>"; 13. } 14. } 15. else 16. alert(result.error.message); 17. } 18. function NWS_CallNews(hrf, num){ 19. if(!NWS_ContainerOk){ 20. document.write("<div id=\"gansyman\"></div>"); 21. NWS_ContainerOk= true; 22. } 23. var feed = new google.feeds.Feed(hrf) 24. feed.setNumEntries(num); 25. feed.load(NWS_GetNewsResults); 26. }Hide line numbers |
1. <html> 2. <!-- 3. scriptdiaries.blogspot.com 4. Righteous Ninja aka Ping Ching. 5. Free to use and modify.--> 6. <head> 7. <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAA40MrnqI6U_ttOMK0wTpPSRQD6263AO_J-cN-o5MVlTXsf8kbcBRDZ3IoIMGa4lhUHoT28Z8OHamBhA"></script> 8. <script type="text/javascript" src="weather.js"></script> 9. <script type="text/javascript" src="newsreader.js"></script> 10. </head> 11. 12. <body> 13. <h2>Weather</h2> 14. <table width="100%"> 15. <tbody> 16. <tr> 17. <td> 18. <select onChange="YW_CallWeather(this.options[this.selectedIndex].value)"> 19. <option value="http://weather.yahooapis.com/forecastrss?p=CEXX0001&u=c">Colombo</option> 20. <option value="http://weather.yahooapis.com/forecastrss?p=CEXX0002&u=c">Moratuwa</option> 21. <option value="http://weather.yahooapis.com/forecastrss?p=CEXX0003&u=c">Negombo</option> 22. <option value="http://weather.yahooapis.com/forecastrss?p=CEXX0004&u=c">Sri Jayawardenepura</option> 23. <option value="http://weather.yahooapis.com/forecastrss?p=CEXX0005&u=c">Katunayake</option> 24. </select> 25. </td> 26. </tr> 27. <tr> 28. <td> 29. <script> 30. YW_CallWeather("http://weather.yahooapis.com/forecastrss?p=CEXX0001&u=c"); 31. </script> 32. </td> 33. </tr> 34. </tbody> 35. </table> 36. 37. <h2>News</h2> 38. <script> 39. NWS_CallNews("http://www.dailymirror.lk/DM_BLOG/RSS/FrontPageRSS.xml",3); 40. NWS_CallNews("http://www.lankanewspapers.com/news/rss.xml",3); 41. </script> 42. 43. </body> 44. </html>Hide line numbers |
1. /* scriptdiaries.blogspot.com 2. Righteous Ninja aka Ping Ching. 3. Free to use and modify.*/ 4. 5. var SXY_cutegirls = new Array("http://codediaries.com/widgets/cutelnka/wid_cutelnka_anarkalli.jpg", 6. "http://codediaries.com/widgets/cutelnka/wid_cutelnka_nadeeka.jpg", 7. "http://codediaries.com/widgets/cutelnka/wid_cutelnka_derana.jpg"); 8. 9. var SXY_cutequotes = new Array( 10. "Sex without love is an empty experience, but as empty experiences go, it's one of the best.", 11. "Sex is not the answer. Sex is the question. Yes is the answer.", 12. "Sex without love is an empty experience, but as empty experiences go, it's one of the best.", 13. "The sex was so good that even the neighbors had a cigarette.", 14. "The difference between pornography and erotica is lighting.", 15. "Sex is like a bridge game; if you don't have a good partner, you better have a good hand." 16. ); 17. 18. function SXY_DoSexyWidget(){ 19. document.getElementById('cutelankapanel').innerHTML= 20. "<center>"+ 21. "<img src=\""+SXY_cutegirls[Math.round((SXY_cutegirls.length-1)*Math.random())]+"\"/>"+ 22. "<br/>"+ 23. SXY_cutequotes[Math.round((SXY_cutequotes.length-1)*Math.random())]+ 24. "</center>"; 25. }Hide line numbers |
1. <html> 2. <!-- 3. scriptdiaries.blogspot.com 4. Righteous Ninja aka Ping Ching. 5. Free to use and modify.--> 6. <head> 7. 8. <style TYPE="text/css"> 9. .cutelanka_quotes{font-family:arial;font-size:11px;color:#ffffff;} 10. </style> 11. 12. <script type="text/javascript" src="sexywidget.js"></script> 13. 14. </head> 15. <body> 16. 17. <table border="0" cellpadding="0" cellspacing="0" width="190px"> 18. <tbody> 19. <tr><td background="frame_top.gif" height="10px"></td></tr> 20. <tr><td bgcolor="#000000" class="cutelanka_quotes"><div id="cutelankapanel" width="100%"></div></td> 21. </tr><tr><td background="frame_bottom.gif" height="10px"></td></tr> 22. </tbody> 23. </table> 24. <script> 25. SXY_DoSexyWidget(); 26. </script> 27. </body> 28. </html>Hide line numbers |
Learn more about this Widget Super sexy widget that displays a random hot girl with a sexy and funny quote. Refresh page for a different quote and image. This can be easily changed to include any images and any number of quotes. Pure javascript only. |
Learn more about this widget A RSS feed widget that displays the news and weather in Sri Lanka. This uses Google's feed API, Yahoo's weather RSS feed and the feeds from two Sri Lankan Newspapers. This widget can be easily adapted to display news and weather from any country or a combination of countries. |
Learn more about this widget A twiter widget that displays what has been on Kim Kardashian's mind for the past week. This widget can be easily adapted to display any celebrity or entity on twittter. |
Learn more about this widget A twiter widget that displays what has been on Paris Hilton's mind for the past week. This widget can be easily adapted to display any celebrity or entity on Twittter. Pure Javascript only. Using Twitter and Yahoo APIs. |