Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    Jan 2013
    Location
    Germany
    Posts
    578
    Thanks
    4
    Thanked 77 Times in 77 Posts
    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".

  • Users who have thanked Airblader for this post:

    stephen_ (01-26-2013)

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jan 2013
    Location
    Germany
    Posts
    578
    Thanks
    4
    Thanked 77 Times in 77 Posts
    JavaScript. It's not the same at all.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •