{"id":4310,"date":"2012-12-23T18:29:39","date_gmt":"2012-12-23T18:29:39","guid":{"rendered":"http:\/\/zerokidz.com\/ideas\/?p=4310"},"modified":"2014-05-24T02:45:33","modified_gmt":"2014-05-24T06:45:33","slug":"twitter-streaming-api-examples","status":"publish","type":"post","link":"https:\/\/reactivemusic.net\/?p=4310","title":{"rendered":"Twitter streaming API examples"},"content":{"rendered":"<p>Update 5\/2014 &#8211; all of these examples are broken due to Twitter API upgrade that requires OAUTH instead of user\/password. Have left this post &#8211; as an example of what you can do. For examples of alternatives, see the internet-sensors projects:\u00a0<a href=\"https:\/\/github.com\/tkzic\/internet-sensors\">https:\/\/github.com\/tkzic\/internet-sensors<\/a><\/p>\n<p><a href=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-12190\" title=\"Screen Shot 2014-05-24 at 2.41.32 AM\" src=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png\" alt=\"\" width=\"300\" height=\"70\" srcset=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png 300w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-1024x239.png 1024w, https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM.png 1462w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&#8212; original post &#8212;<\/p>\n<p>Here is an example that I actually got working to track mention of dogs&#8230; You need to replace USER:PASS with your Twitter login and password. The JSON search results will be written to the file tweets.json.<\/p>\n<p>A running tally of results will be displayed to the console while this is running.<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">curl https:\/\/stream.twitter.com\/1\/statuses\/filter.json -u USER:PASSWORD -d &quot;track=dog&quot; &gt; tweets.json<\/pre>\n<p>This one searches for #cats (hashtag)<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">curl https:\/\/stream.twitter.com\/1\/statuses\/filter.json -u USERNAME:PASSWORD -d &quot;track=#cats&quot; &gt; tweets.json<\/pre>\n<p><a href=\"https:\/\/dev.twitter.com\/discussions\/2403\">https:\/\/dev.twitter.com\/discussions\/2403<\/a><\/p>\n<p>Haven&#8217;t tried this one:<\/p>\n<p>Do you have a specific example which doesn&#8217;t appear to work? Following Taylor&#8217;s advice, I was able to find several streaming entries tracking the &#8220;photo&#8221; keyword:<\/p>\n<div>\n<div>\n<ol>\n<li>\n<pre>curl https:\/\/stream.twitter.com\/1\/statuses\/filter.json -d &#039;track=photo&#039; -u [username]:[password] -# | grep &quot;\\&quot;media_url\\&quot;&quot;<\/pre>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p>Here is a technique (in the answer) which tracks when the stream gets a hit<\/p>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/4786786\/using-curl-to-update-mysql-when-curl-spits-out-json\">http:\/\/stackoverflow.com\/questions\/4786786\/using-curl-to-update-mysql-when-curl-spits-out-json<\/a><\/p>\n<p>Here are other useful links and examples:<\/p>\n<p>basic curl statuses example, no filters<\/p>\n<p><a href=\"https:\/\/dev.twitter.com\/discussions\/9911\">https:\/\/dev.twitter.com\/discussions\/9911<\/a><\/p>\n<p>Look at the post from Matt Seward to do locations&#8230;<\/p>\n<p><a href=\"https:\/\/dev.twitter.com\/discussions\/3779\">https:\/\/dev.twitter.com\/discussions\/3779<\/a><\/p>\n<p>followers:<\/p>\n<p><a href=\"https:\/\/dev.twitter.com\/discussions\/4067\">https:\/\/dev.twitter.com\/discussions\/4067<\/a><\/p>\n<p>tracking:<\/p>\n<p><a href=\"https:\/\/dev.twitter.com\/discussions\/5520\">https:\/\/dev.twitter.com\/discussions\/5520<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update 5\/2014 &#8211; all of these examples are broken due to Twitter API upgrade that requires OAUTH instead of user\/password. Have left this post &#8211; as an example of what you can do. For examples of alternatives, see the internet-sensors projects:\u00a0https:\/\/github.com\/tkzic\/internet-sensors &#8212; original post &#8212; Here is an example that I actually got working to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/reactivemusic.net\/?p=4310\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Twitter streaming API examples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[143],"tags":[6,190,25,136,12],"class_list":["post-4310","post","type-post","status-publish","format-standard","hentry","category-interactive-media-art","tag-interactive-media","tag-portfolio","tag-programming","tag-twitter","tag-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Twitter streaming API examples - reactive music<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/reactivemusic.net\/?p=4310\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Twitter streaming API examples - reactive music\" \/>\n<meta property=\"og:description\" content=\"Update 5\/2014 &#8211; all of these examples are broken due to Twitter API upgrade that requires OAUTH instead of user\/password. Have left this post &#8211; as an example of what you can do. For examples of alternatives, see the internet-sensors projects:\u00a0https:\/\/github.com\/tkzic\/internet-sensors &#8212; original post &#8212; Here is an example that I actually got working to &hellip; Continue reading &quot;Twitter streaming API examples&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/reactivemusic.net\/?p=4310\" \/>\n<meta property=\"og:site_name\" content=\"reactive music\" \/>\n<meta property=\"article:published_time\" content=\"2012-12-23T18:29:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-05-24T06:45:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png\" \/>\n<meta name=\"author\" content=\"Tom Zicarelli\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tom Zicarelli\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310\"},\"author\":{\"name\":\"Tom Zicarelli\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"headline\":\"Twitter streaming API examples\",\"datePublished\":\"2012-12-23T18:29:39+00:00\",\"dateModified\":\"2014-05-24T06:45:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310\"},\"wordCount\":218,\"image\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png\",\"keywords\":[\"interactive media\",\"portfolio\",\"programming\",\"Twitter\",\"web development\"],\"articleSection\":[\"interactive media art\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310\",\"name\":\"Twitter streaming API examples - reactive music\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png\",\"datePublished\":\"2012-12-23T18:29:39+00:00\",\"dateModified\":\"2014-05-24T06:45:33+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/reactivemusic.net\\\/?p=4310\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#primaryimage\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/Screen-Shot-2014-05-24-at-2.41.32-AM.png\",\"contentUrl\":\"https:\\\/\\\/reactivemusic.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/Screen-Shot-2014-05-24-at-2.41.32-AM.png\",\"width\":\"1462\",\"height\":\"342\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4310#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/reactivemusic.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Twitter streaming API examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/\",\"name\":\"reactive music\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/reactivemusic.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\",\"name\":\"Tom Zicarelli\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"caption\":\"Tom Zicarelli\"},\"sameAs\":[\"http:\\\/\\\/tomzicarelli.com\"],\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Twitter streaming API examples - reactive music","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/reactivemusic.net\/?p=4310","og_locale":"en_US","og_type":"article","og_title":"Twitter streaming API examples - reactive music","og_description":"Update 5\/2014 &#8211; all of these examples are broken due to Twitter API upgrade that requires OAUTH instead of user\/password. Have left this post &#8211; as an example of what you can do. For examples of alternatives, see the internet-sensors projects:\u00a0https:\/\/github.com\/tkzic\/internet-sensors &#8212; original post &#8212; Here is an example that I actually got working to &hellip; Continue reading \"Twitter streaming API examples\"","og_url":"https:\/\/reactivemusic.net\/?p=4310","og_site_name":"reactive music","article_published_time":"2012-12-23T18:29:39+00:00","article_modified_time":"2014-05-24T06:45:33+00:00","og_image":[{"url":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png","type":"","width":"","height":""}],"author":"Tom Zicarelli","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tom Zicarelli","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/reactivemusic.net\/?p=4310#article","isPartOf":{"@id":"https:\/\/reactivemusic.net\/?p=4310"},"author":{"name":"Tom Zicarelli","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"headline":"Twitter streaming API examples","datePublished":"2012-12-23T18:29:39+00:00","dateModified":"2014-05-24T06:45:33+00:00","mainEntityOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=4310"},"wordCount":218,"image":{"@id":"https:\/\/reactivemusic.net\/?p=4310#primaryimage"},"thumbnailUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png","keywords":["interactive media","portfolio","programming","Twitter","web development"],"articleSection":["interactive media art"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/reactivemusic.net\/?p=4310","url":"https:\/\/reactivemusic.net\/?p=4310","name":"Twitter streaming API examples - reactive music","isPartOf":{"@id":"https:\/\/reactivemusic.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=4310#primaryimage"},"image":{"@id":"https:\/\/reactivemusic.net\/?p=4310#primaryimage"},"thumbnailUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM-300x70.png","datePublished":"2012-12-23T18:29:39+00:00","dateModified":"2014-05-24T06:45:33+00:00","author":{"@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"breadcrumb":{"@id":"https:\/\/reactivemusic.net\/?p=4310#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/reactivemusic.net\/?p=4310"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/reactivemusic.net\/?p=4310#primaryimage","url":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM.png","contentUrl":"https:\/\/reactivemusic.net\/wp-content\/uploads\/2012\/12\/Screen-Shot-2014-05-24-at-2.41.32-AM.png","width":"1462","height":"342"},{"@type":"BreadcrumbList","@id":"https:\/\/reactivemusic.net\/?p=4310#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/reactivemusic.net\/"},{"@type":"ListItem","position":2,"name":"Twitter streaming API examples"}]},{"@type":"WebSite","@id":"https:\/\/reactivemusic.net\/#website","url":"https:\/\/reactivemusic.net\/","name":"reactive music","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/reactivemusic.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571","name":"Tom Zicarelli","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","caption":"Tom Zicarelli"},"sameAs":["http:\/\/tomzicarelli.com"],"url":"https:\/\/reactivemusic.net\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/4310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4310"}],"version-history":[{"count":16,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/4310\/revisions"}],"predecessor-version":[{"id":4312,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/4310\/revisions\/4312"}],"wp:attachment":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}