Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1166 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

jQuery and Twitter

Thread title: jQuery and Twitter
Reply    
    Thread tools Search this thread Display Modes  
06-13-2009, 11:03 PM
#1
fredkelly is offline fredkelly
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

fredkelly is on a distinguished road

  Old  jQuery and Twitter

Hi There,

I'm trying to make a simple script to get my most recent twitter update using jQuery and the twitter API. The simple function I have is below:

Code:
function get_twitter() {
	$.getJSON("http://twitter.com/statuses/user_timeline/fredkelly.json?count=1&callback=?", function (data){
	  	alert(data);
	});
}
This currently returns '[Object] object' or similar. I think I need to decode the response and then somehow select parts of the response e.g. text and date of the message - but I'm not sure how to go about this.

Could anyone offer some help - I'm not sure if I'm going about this in the right way at all!

Cheers,
Fred

Reply With Quote
06-13-2009, 11:14 PM
#2
46Bit is offline 46Bit
Status: Member
Join date: Mar 2009
Location: Yorkshire
Expertise: Web Development
Software:
 
Posts: 275
iTrader: 10 / 100%
 

46Bit is on a distinguished road

Send a message via MSN to 46Bit Send a message via Skype™ to 46Bit

  Old

Code:
function (data, textStatus) {
  // data will be a jsonObj
  // textStatus will be one of the following values: 
  //   "timeout","error","notmodified","success","parsererror"
  this; // the options for this ajax request
}
From http://docs.jquery.com/Ajax/jQuery.getJSON.

EDIT: Sorry, misunderstood your question, try http://blog.reindel.com/2007/10/02/p...nd-javascript/.

Reply With Quote
06-14-2009, 12:19 PM
#3
fredkelly is offline fredkelly
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

fredkelly is on a distinguished road

  Old

Still struggling to get this working - I just want to display the single most recent message, and as such, I don't think using a loop (as in those examples) is necessary?

I simply want to decode the jQuery response - I think this might be done using eval() perhaps? - but I'm not sure how to implement this!

Thanks,
Fred

Reply With Quote
06-14-2009, 12:26 PM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

jQuery will automatically parse the JSON string into a JavaScript object for you to use.

Code:
function get_twitter() {
	$.getJSON("http://twitter.com/statuses/user_timeline/fredkelly.json?count=1&callback=?", function (data){
		// Alert the twitter message only
		alert(data[0].text);
		// Add it to the page (assumes you have an element id "foo")
		document.getElementById("foo").innerHTML = data[0].text;
	});
}

Reply With Quote
06-14-2009, 01:00 PM
#5
fredkelly is offline fredkelly
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

fredkelly is on a distinguished road

  Old

PERFECT!

Much appreciated Salathe!

Reply With Quote
10-31-2009, 01:09 PM
#6
daisy7386 is offline daisy7386
Status: I'm new around here
Join date: Oct 2009
Location:
Expertise:
Software:
 
Posts: 1
iTrader: 0 / 0%
 

daisy7386 is on a distinguished road

  Old

thanx for the code its working fine

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed