Google custom search API

notes

API for custom searches from Google…. and a method to spoof the “custom” part of it…

https://code.google.com/apis/console/

https://developers.google.com/custom-search/v1/getting_started

Use this method to build a custom search which searches the whole web…

http://stackoverflow.com/questions/4082966/google-web-search-api-deprecated-what-now

Here is an example of a search using this method with curl – note the API-KEY is removed. You will need to get an API key (see above).

curl "https://www.googleapis.com/customsearch/v1?key=API-KEY&cx=012117491442732664551:egvalbpelhq&q=lectures"

Twitter streaming API examples

Update 5/2014 – all of these examples are broken due to Twitter API upgrade that requires OAUTH instead of user/password. Have left this post – as an example of what you can do. For examples of alternatives, see the internet-sensors projects: https://github.com/tkzic/internet-sensors

— original post —

Here is an example that I actually got working to track mention of dogs… You need to replace USER:PASS with your Twitter login and password. The JSON search results will be written to the file tweets.json.

A running tally of results will be displayed to the console while this is running.

curl https://stream.twitter.com/1/statuses/filter.json -u USER:PASSWORD -d "track=dog" > tweets.json

This one searches for #cats (hashtag)

curl https://stream.twitter.com/1/statuses/filter.json -u USERNAME:PASSWORD -d "track=#cats" > tweets.json

https://dev.twitter.com/discussions/2403

Haven’t tried this one:

Do you have a specific example which doesn’t appear to work? Following Taylor’s advice, I was able to find several streaming entries tracking the “photo” keyword:

  1. curl https://stream.twitter.com/1/statuses/filter.json -d 'track=photo' -u [username]:[password] -# | grep "\"media_url\""

Here is a technique (in the answer) which tracks when the stream gets a hit

http://stackoverflow.com/questions/4786786/using-curl-to-update-mysql-when-curl-spits-out-json

Here are other useful links and examples:

basic curl statuses example, no filters

https://dev.twitter.com/discussions/9911

Look at the post from Matt Seward to do locations…

https://dev.twitter.com/discussions/3779

followers:

https://dev.twitter.com/discussions/4067

tracking:

https://dev.twitter.com/discussions/5520

 

 

curl and oauth

Oauth is the authentication service used by companies like Google and Twitter to protect their API’s.

update 6/2014: For current working examples, see Internet sensors projects: https://reactivemusic.net/?p=5859

original post

notes

A wrapper around curl to support OAuth 2.0: https://github.com/fireteam/curlish

The Google oauth 2.0 tutorial for devices – note: there is a local example in Max teaching examples: google-oauth-readme.txt: https://developers.google.com/accounts/docs/OAuth2ForDevices

How Oauth works.