Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API count parameter

I've got a feeling this is going to be something really simple, but anyway. I've got some code that pulls in my latest Twitter statuses - it's pretty much the standard code everyone is using. However, even though the URL I'm using has the count parameter added...it's not limiting the request to 5 statuses. The code works, well, in so much as it will output 20 statuses instead, just as its set to by default, but I can't get it to limit the number. What have I done wrong? (I've simplified the output down to a body append just to make things easier)

$(document).ready(function(){

var username = 'Mynamewouldbehere';
var format = 'json';
var url = 'http://api.twitter.com/1/statuses/user_timeline/'
    + username + '.' + format + '?callback=?&count=5';

$.ajax({
    url: url,
    dataType: "json",
    timeout: 15000,

    success: function(data)
    {
        $.each(data, function(i,item) {
            $("body").append('<p>' + item.text + '</p>');
        });
    }
});
like image 851
Kerry Avatar asked Apr 06 '26 10:04

Kerry


1 Answers

Use & instead of &amp; in the URL. Your code is currently creating a parameter named amp;count instead of count.

like image 97
interjay Avatar answered Apr 09 '26 12:04

interjay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!