1

Solved

The problem is that Twitter now (stupidly) requires OAuth even for public data. An easy enough workaround is to have a local php script which OAuths and gets the data and access that with Ajax as opposed to Ajaxing twitter directly.


I'm currently trying to pull user timelines from twitter using the Reqwest JavaScript library. However when I do so the request is considered successful but no data is retrieved and the console displays a GET error. The code im trying is as follows:

$.domReady(function () {
    
    $.ajax({
        url: 'http://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitter',
        type: 'jsonp',
        success: function (response) {
            console.log(response);
        },
        error: function (err) {
            console.log(err);
        }
    });

})
Community
  • 1
  • 1
Jordan Adams
  • 434
  • 1
  • 8
  • 18
  • 1
    Twitter API version 1 is deprecated and may no longer be supported (can't remember the exact date). You need to use API 1.1 – DevDave Mar 18 '13 at 13:35
  • I've tried 1.1 and it's also unsuccessful. Post updated – Jordan Adams Mar 18 '13 at 13:36
  • I faced a similar problem and I think you must use OAuth now before being able to make calls to the Twitter API, are you already doing that? I work with C#.net and used LinqToTwitter to solve this – DevDave Mar 18 '13 at 13:38
  • also, I think the syntax has changed a bit (i.e it wouldn't be a simple as changing 1 to 1.1), will try and find an example for you – DevDave Mar 18 '13 at 13:39
  • @Tyler Tried accessing direct through chrome and it says "Bad authentication..." so it's likely and OAuth requirement. Pretty pathetic that you need to OAuth public tweets but I'll give it a shot. And it is jus a case of using 1.1 instead of 1. Checked the API docs :) – Jordan Adams Mar 18 '13 at 13:43
  • 1
    yep! I went through all of this around a month back, really annoying! – DevDave Mar 18 '13 at 13:44

3 Answers3

0

Try to pass parameter jsoncallback. http://jsfiddle.net/CCTKa/

I just got Bad Authentication data error.

inser
  • 1,190
  • 8
  • 17
0

I just updated a plugin of mine to work with the Twitter 1.1 API. Unfortunately, per Twitter's urging, you will have to perform the actual request from server-side code. However, you can pass the response to the plugin and it will take care of the rest. I don't know what framework you are running, but I have already added sample code for making the request in C#, and will be adding sample code for PHP, shortly.

Zachary Kniebel
  • 4,686
  • 3
  • 29
  • 53
0

If we want to, we can still parse their pages and reimplement at least a bit of lost functionality with pure client-side JS.

What we need is: a CORS proxy that can deal with HTTPS pages (the only I know is YQL APIs) and the knowledge of how the information is retreived on their public pages. Keeping this in mind, we can fetch, for example, recent 20 tweets from a user, as I did in the demo: http://jsbin.com/agejol/1 (click "Edit in JSBin" to view the code)

P.S. I know this may violate their policy but I care about it just as much as they cared about us when they dropped all their client-side APIs.

Multiversum
  • 323
  • 3
  • 5