Twitter Reader

From OpenSocial Directory

Jump to: navigation, search
Thumbnail
twitter.png
Application Details
Description Display your last Twitter posts
Publisher Diogo Peixoto
Author Diogo Peixoto
Code http://www.diogopeixoto.com/opensocial/twitter.xml
Genre Micro-Blogging

Image:Example.jpg==Reviews== Add a Review
Template:Twitter Reader Reviews

[edit] Comments

Leave a comment

Your Name:
Heading:
Comment:


[edit] Code

View Code

  <?xml version="1.0" encoding="UTF-8" ?> 
  <Module>
  <ModulePrefs title="Twitter Reader - Beta" title_url="http://www.diogopeixoto.com/" author="Diogo Peixoto" author_email="diogopeixoto@gmail.com" thumbnail="http://www.diogopeixoto.com/opensocial/twitter.png" height="350" description="Display your last Twitter posts" /> 
  <UserPref name="login_twitter" display_name="Your Twitter login:" /> 
  <Content type="html">
  <![CDATA[ 
<style> #content_div { width:100%; font-size: 80%; margin: 10px; background-color: #FFFFFF;}
a:link { text-decoration:none;}
</style>


<div id=content_div></div>

<script type="text/javascript">

// Get userprefs
var prefs = new _IG_Prefs(__MODULE_ID__);
var login = prefs.getString("login_twitter");

var url_feed = "http://twitter.com/statuses/user_timeline.rss?id=" + login;

_IG_FetchFeedAsJSON(
url_feed,
function(feed) {
if (feed == null){
alert("Comments not found.");
return;
}


var html = "";

html += "<div><h2><b>" + feed.Description + "</b></h2></div><br>";

if (feed.Entry) {

for (var i = 0; i < feed.Entry.length; i++) {

var date = new Date();
date.setTime((feed.Entry[i].Date) *1000);
var datehtml ="";
datehtml += date.toLocaleDateString();
datehtml += " ";
datehtml += date.toLocaleTimeString();

var text ="";

try {
   pos1 = feed.Entry[i].Title.indexOf(':') + 2;
   text = feed.Entry[i].Title.substring(pos1,feed.Entry[i].Title.length);
}catch(err) { text = feed.Entry[i].Title }


html += "<div>"
+ "<a target='new' href='" + feed.Entry[i].Link + "'>"
+ text
+ "</a> <small><small>posted: " + datehtml + "</small></small><hr>";
html += "</div>";
}
}
_gel("content_div").innerHTML = html;

},10,false);


</script>



  ]]> 
  </Content>
  </Module>

Page Rating

Rating: 2.3/5 (7 votes cast)

Personal tools
communication