Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing out profile image in Twitter RSS feed (media:content)

Status
Not open for further replies.

myatia

Programmer
Nov 21, 2002
232
0
0
I'm using jQuery to display a Twitter feed on my website. I would like to be able to parse out the user's profile image, which is passed in a "media:content" or "google:image" elements. I've tried things like this:

author = $('item', xml).find('google:image').eq(0).text();
author = $('item', xml).find('media:content').href;

I'm just not sure what the exact syntax is. Any help would be appreciated. My code and RSS feed are below. Thanks!

Code:
$(document).ready(function(){ 
	 
	$.get("/includes/twitter-functions.asp", {a:'xml', user:'mbac09', list:'keyword'}, function(xml){

		// Build an HTML string
		var myHTMLOutput = '';
		var s = '';
		var i;  
		var ci;
		var description;

		for (i=0; i<15; i++) {

			ci = $('item', xml).eq(i);
			
			description = ci.find('title').eq(0).text();
			// description = getTwitterDisplay(description);			

			myHTMLOutput = myHTMLOutput + '<p>' + author + ': ' + description + "<br /><small><em>" + pubDate + "</em></small></p>";

		}

		// Update the DIV called Content Area with the HTML string
		$("#Twitter").append(myHTMLOutput);
	});
});

The RSS feed from Twitter looks like this:

Code:
    <item>
      <title>RT @bschaaf Great tool used by Tommy Stephens at #MBAC09 - Virtual Magnifying Glass. Plan to use it in my class [URL unfurl="true"]http://tinyurl.com/lsmkdu</title>[/URL]

      <link>[URL unfurl="true"]http://twitter.com/lwedul/statuses/2309366447</link>[/URL]
      <description>RT &lt;a href="[URL unfurl="true"]http://twitter.com/bschaaf"&gt;@bschaaf&lt;/a&gt;[/URL] Great tool used by Tommy Stephens at &lt;a href="[URL unfurl="true"]http://search.twitter.com/search?q=%23MBAC09"&gt;#&lt;b&gt;MBAC09&lt;/b&gt;&lt;/a&gt;[/URL] - Virtual Magnifying Glass. Plan to use it in my class &lt;a href="[URL unfurl="true"]http://tinyurl.com/lsmkdu"&gt;http://tinyurl.com/lsmkdu&lt;/a&gt;</description>[/URL]

      <pubDate>Wed, 24 Jun 2009 12:00:09 +0000</pubDate>
      <guid>[URL unfurl="true"]http://twitter.com/lwedul/statuses/2309366447</guid>[/URL]
      <author>lwedul@twitter.com (Linda Wedul)</author>
      <media:content type="image/jpg" url="[URL unfurl="true"]http://s3.amazonaws.com/twitter_production/profile_images/276827204/linda_opt_normal.jpg"[/URL] width="48" height="48"/>
      <google:image_link>[URL unfurl="true"]http://s3.amazonaws.com/twitter_production/profile_images/276827204/linda_opt_normal.jpg</google:image_link>[/URL]
    </item>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top