Windows Azure Mobile Services JavaScript code for Twitter API

47 Views Asked by At

I saw a video on Channel9 where Nick Harris uses Scheduler option of Azure Mobile Services to retrieve Tweets of user. His code is in JavaScript. When I tried re-writing his code I got an error stating {"errors":[{"message":"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.","code":64}]}

Snapshot of the code: enter image description here

What should be my updated URL for searching?

2

There are 2 best solutions below

0
On

I'm not sure how old the tutorial you're following is, but API 1.1 has been current for several years so this search endpoint will indeed not work any longer.

The API endpoint you want to use with API 1.1 is https://api.twitter.com/1.1/search/tweets.json (documented on the Twitter Developer website here).

However, note that unlike the previous API version, this also now requires authentication, so you will not be able to simply switch out the endpoint for the one in the code you're currently using - you'll need to do an OAuth dance in your code as well.

0
On

Or if you're using the JavaScript backend for your Azure Mobile App, you can use a node module (I use this one) to hook into the Twitter Streaming API. I did this in my Tweet Monkey (blog,code) project and it's really brief and easy. Here's some help using node modules with Azure Mobile Apps.