Kerry
Kerry

Reputation: 217

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>');
        });
    }
});

Upvotes: 3

Views: 1115

Answers (2)

interjay
interjay

Reputation: 110069

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

Upvotes: 4

ingorichter
ingorichter

Reputation: 303

Without the 'callback=?' argument it works as expected.

Upvotes: 0

Related Questions