15

I'm working on a basic personal homepage, consists of a single html document, a .css and jquery*.js file. I want to create a blog-ish look via fetching page content from tweets. The standart widget doesn't fit to the look of the page.

I can fetch public tweets from any account with no authentication crap (it's crap because it public data anyway) via API v1. But with API v1.1, it returns authentication error. It wants me to authenticate to fetch public data. Try to navigate this url. it shows ({"errors":[{"message":"Bad Authentication data","code":215}]});.

My question is is there a way to fetch public tweets via client side js? I don't want to create an app to just fetch public data. I don't wan't to use identi.ca or else, but Twitter pushes me to do.


Upon the comment of Zachary Kinebel to Norguard's answer, I thought, as a comment of Norguard's might be helpful to others, I should put it here:


/search.json?q=from:nerdswguitars === recent tweets by NerdsWGuitars /search.json?q=to:nerdswguitars === recent tweets to NerdsWGuitars /search.json?q=from:nerdswguitars OR to:nerdswguitars === both. /search.json?q=@nerdswguitars === posts involving NerdsWGuitars. /search.json?q=#nerdswithguitars === posts trending "nerdswithguitars". But you MUST make sure that you're properly URL encoding the query. Read more here: https://dev.twitter.com/docs/using-search and if you can't find what it is that you're looking for, out of this, then you need to be a lot more specific

  • Just tried G+ for same: wants oauth too. –  Oct 24 '12 at 19:37
  • 1
    This post helped a lot and I just completed the update for my twitter plugin, which uses JS to render and parse the requested Tweets (which must be retrieved via server-side scripting, per the new API - 1.1). The plugin can be found at http://zkniebel.github.com/jquery-twitter-feed/ and it includes sample server code to help get you going. The sample code uses `statuses/user_time` but the new `search/tweets` can be implemented with little change (update the URL and add/change the desired parameters). – Zachary Kniebel Mar 18 '13 at 16:52
  • 1
    @ZacharyKniebel and G: Twitter has now deprecated the Search API, and are forcing you to make an application, and do, at-minimum, application-level authentication, to make GET requests of their timeline. This is being sunsetted ~May. – Norguard Apr 23 '13 at 20:15
  • @Norguard - read my comment above yours - I have addressed this issue – Zachary Kniebel Apr 25 '13 at 10:47

2 Answers2

10

EDIT

In the wonderful world of bad ideas, Twitter is sunsetting this answer, as of May 2013, and will require, at minimum, that you either use one of their widgets, and shoehorn it in, or that you set up an application and do application-level authentication, even for public-timeline GET requests.

If they change their mind, or delay the throwing of the switch, this will at least continue to be here.


Use the Search API:

"http://search.twitter.com/search.json?q=nerdswguitars"

You can use the URL-encoded # or @ in front of search terms. You can also use keywords like from or to, and specify limits, et cetera.

Norguard
  • 26,167
  • 5
  • 41
  • 49
  • What if someone mentioned me, or arbitarily use my name with having no relation to me? What if my user name is dave or jim or sth. else that a billion person has? There is no chance to limit the search to usernames (in the api, I know it is possible to filter manually). I won't search my **public** tweets. –  Oct 25 '12 at 17:16
  • Read the Search API documentation - it lays out all kinds of parameters. – Norguard Oct 25 '12 at 19:15
  • 6
    @g_kaya `/search.json?q=from:nerdswguitars` === recent tweets by NerdsWGuitars `/search.json?q=to:nerdswguitars` === recent tweets to NerdsWGuitars `/search.json?q=from:nerdswguitars OR to:nerdswguitars` === both. `/search.json?q=@nerdswguitars` === posts involving NerdsWGuitars. `/search.json?q=#nerdswithguitars` === posts trending "nerdswithguitars". But you ***MUST*** make sure that you're properly URL encoding the query. Read more here: https://dev.twitter.com/docs/using-search *and if you can't find what it is that you're looking for, out of this, then you need to be a lot more specific* – Norguard Oct 25 '12 at 19:34
  • 1
    Thanks a lot. As far as I see, your answer is the best possible solution, I can use `/q=from:x` to get only x's tweets, but I'm really disappointed with the way Twitter altered their API. –  Oct 25 '12 at 21:30
  • I have to say, this is the best solution and is way too hard to find. I have been looking for this answer all day and it wasn't until I searched for "jQuery Twitter 1.1 widgets" that I finally found this. Anyone looking to update deprecated timeline plugins needs to see this! UP+++++++++ – Zachary Kniebel Mar 16 '13 at 19:50
  • 7
    Unfortunately this is exactly what Twitter has turned off. – Jimbo Jonny Jun 12 '13 at 16:19
  • 1
    Yep, search.twitter.com is no more. – Jordan Reiter Jun 18 '13 at 18:32
  • Down voted the answer because it is no longer relevant: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview." – Wes Modes May 22 '16 at 22:47
  • @wesmodes There’s not a whole lot I can do about that, Wes. I can’t delete an accepted answer (hence why I updated it in 2013, to mention that 1.0 was being sunset). Thanks for letting me know what I already (preemptively, I might add) admitted to, as the first sentence in my edited answer. Perhaps, instead of letting me know, you could instead let the question author know, so that he can deselect my answer. If you would prefer that I write “Edit 2” and go through OAuth tutorials, instead, let me know. – Norguard May 22 '16 at 23:53
6

You can use Mooch, a small application designed to solve this exact problem. Setting up a new Mooch service is very simple, and utilizes Heroku. The deployment process requires the Heroku Toolbelt application.

Step 1: Create a Twitter app

Step 2: Get Mooch

  • Clone the Git repository (git clone git@github.com:eloquent/mooch.git).
  • Change into the Mooch root directory.

Step 3: Create a Heroku app

  • Sign in with Heroku Toolbelt (heroku login).
  • Create a new app with heroku create.

Step 4: Configuration

Mooch authenticates requests to the Twitter API using the application-only authentication method. This requires the consumer key and secret from the Twitter application created in step 1.

Example authentication configuration

heroku config:set MOOCH_CONSUMER_KEY=xvz1evFS4wEEPTGEFPHBog
heroku config:set MOOCH_CONSUMER_SECRET=L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg

Step 5: Deploy

  • git push heroku master

The new Mooch service should now be ready for use. Check the Heroku dashboard for the service's location.

For more detailed configuration instructions, a demo application and more, check out the Mooch README on GitHub.

Community
  • 1
  • 1
ezzatron
  • 779
  • 6
  • 15