Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-26-2013, 06:04 PM   PM User | #1
stephen_
New Coder

 
Join Date: Jan 2012
Posts: 49
Thanks: 13
Thanked 0 Times in 0 Posts
stephen_ is an unknown quantity at this point
Limit reposnses in twitter call

Can I add a variable to limit the amount of responses I get back from the get request?

Code:
<script type="text/javascript">
$(document).ready(function() {
	$.getJSON('http://search.twitter.com/search.json?q=uspca&lang=en&callback=?', function(data) {
		var data = data.results;
		var html = '<ul class="list-how-works">';	
		for(var i=0; i<data.length; i++) {
	    	html += "<li><a href='http://twitter.com/" + data[i].from_user + "'>@" 
                      + data[i].from_user + "</a>: " + data[i].text + "</li>";
		}
		html += "</ul>"
    	$('.twitter-info').html(html);
	});
});
</script>
stephen_ is offline   Reply With Quote
Old 01-26-2013, 06:42 PM   PM User | #2
Airblader
Regular Coder

 
Join Date: Jan 2013
Location: Germany
Posts: 368
Thanks: 3
Thanked 44 Times in 44 Posts
Airblader can only hope to improve
That's what an API is for: https://dev.twitter.com/docs/api/1/get/search

I've never used the Twitter API before but I'd say you're looking for "rpp".
Airblader is offline   Reply With Quote
Users who have thanked Airblader for this post:
stephen_ (01-26-2013)
Old 01-26-2013, 06:46 PM   PM User | #3
stephen_
New Coder

 
Join Date: Jan 2012
Posts: 49
Thanks: 13
Thanked 0 Times in 0 Posts
stephen_ is an unknown quantity at this point
Quote:
Originally Posted by Airblader View Post
That's what an API is for: https://dev.twitter.com/docs/api/1/get/search

I've never used the Twitter API before but I'd say you're looking for "rpp".
thanks for that - I'm aware the API uses 'rpp=n' for the number of tweets to be displayed I'd like however to add it to the script I have found above.

Okay apologies I'm tired and a newbie to java and using api#s i've since added the parameter to the URL:

$.getJSON('http://search.twitter.com/search.json?q=uspca&lang=en&rpp=5&callback=?', function(data) {

Full script is;
Code:
<script type="text/javascript">
$(document).ready(function() {
	$.getJSON('http://search.twitter.com/search.json?q=uspca&lang=en&rpp=5&callback=?', function(data) {
		var data = data.results;
		var html = '<ul class="list-how-works">';	
		for(var i=0; i<data.length; i++) {
	    	html += "<li><a href='http://twitter.com/" + data[i].from_user + "'>@" 
                      + data[i].from_user + "</a>: " + data[i].text + "</li>";
		}
		html += "</ul>"
    	$('.twitter-info').html(html);
	});
});
</script>

Last edited by stephen_; 01-26-2013 at 06:49 PM..
stephen_ is offline   Reply With Quote
Old 01-26-2013, 06:54 PM   PM User | #4
Airblader
Regular Coder

 
Join Date: Jan 2013
Location: Germany
Posts: 368
Thanks: 3
Thanked 44 Times in 44 Posts
Airblader can only hope to improve
JavaScript. It's not the same – at all.
Airblader is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:31 PM.


Advertisement
Log in to turn off these ads.