Skip to content

Instantly share code, notes, and snippets.

@fons
Created December 7, 2010 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fons/731357 to your computer and use it in GitHub Desktop.
Save fons/731357 to your computer and use it in GitHub Desktop.
example of the search api in cl-twitter
(define-element search-ref ( (metadata search-ref-metadata))
"An individual search reference"
(id "Integer ID of message" nil)
(text "The text of the tweet" nil)
(to-user "Screen name" nil)
(to-user-id "ID of receiver" nil)
(from-user "Screen name" nil)
(from-user-id "ID of sender" nil)
(iso-language-code "Two character language code for content" nil)
(source "Source of the result" nil)
(profile-image-url "The profile image of the sender")
(created-at "The date of message creation" nil)
(metadata nil "")
(geo "FIXME unparsed"))
(defun do-search (query &key (max-pages 15) )
(let ((ht (make-hash-table :test 'equal :size 1500)))
(labels ((collect-it (slst)
(dolist (item slst)
(setf (gethash (search-ref-id item) ht) item))))
(with-paging (:collector #'collect-it :max-pages max-pages :test #'rate-limit-exceeded ) (search-twitter query))
ht)))
(defun search-twitter (query &rest args &key (callback nil) (lang nil) (locale nil) (rpp nil) (page nil)
(since-id nil) (until nil) (geocode nil) (show-user nil) (result-type nil) )
(declare (ignore callback lang locale rpp page since-id until geocode show-user result-type ))
(apply 'twitter-op :search :q query (rem-nil-keywords args '(:callback :geocode :lang :until))))
TWIT> (setf *R* (do-search "Ponies"))
; Evaluation aborted.
TWIT> (setf *R* (do-search "Ponies"))
#<HASH-TABLE :TEST EQUAL :COUNT 1499 {100413AF21}>
TWIT> (maphash (lambda (k v) (print-search-ref v)) *R*)
[...]
[Mon, 06 Dec 2010 07:54:53 +0000] TheMightyAlexx_: I love ponies and sunshine and *falls* privates!
[Mon, 06 Dec 2010 07:52:51 +0000] HabboGuy: @Dq231 I LIKE PONIES AND SUNINE AND DOOSH SNOOKIE
[Mon, 06 Dec 2010 07:51:41 +0000] stationbred: That fancy Spanish horse and his grassyarse. Why can't he just say &quot;thanks&quot; like the rest of us common or garden ponies...
[Mon, 06 Dec 2010 07:37:24 +0000] DSchiller: Off to see the ponies..in the rain! Looove
[Mon, 06 Dec 2010 07:29:21 +0000] BarackOBoogie: &quot;@Meezy_TaughtYou: @snazmindanielle Did you just call us ponies?? YOU WERE A DOLPHIN!&quot; (Remember That Noise!)
[Mon, 06 Dec 2010 07:28:44 +0000] Meezy_TaughtYou: @snazmindanielle Did you just call us ponies?? YOU WERE A DOLPHIN!
[Mon, 06 Dec 2010 07:28:11 +0000] HoneeBeeBesos: RT @snazmindanielle: &quot;@FashionGenius90: #NoOneLikesYouBecause you went to WY *shots fired* haha (jadakiss voice)&quot;&lt;&lt;this is #dumb. Damned ponies
[Mon, 06 Dec 2010 07:27:40 +0000] snazmindanielle: &quot;@FashionGenius90: #NoOneLikesYouBecause you went to WY *shots fired* haha (jadakiss voice)&quot;&lt;&lt;this is #dumb. Damned ponies
[Mon, 06 Dec 2010 07:26:45 +0000] CrayonChewer: @kuiperfrog WATCHING PONIES WITHOUT ME?!?
[Mon, 06 Dec 2010 07:22:21 +0000] TheMightyAlexx_: @DopeDoofs Suck a ponies balls bitch &gt;:D
I don't do 1v1 in skate, I do 2v1(; me against you and someone else!
[Mon, 06 Dec 2010 07:22:17 +0000] kuiperfrog: @CrayonChewer Come watch things with me &amp; momo we are... watching more ponies orz
[Mon, 06 Dec 2010 07:22:13 +0000] bookmooch: Miss Parker's Ponies (Zebra Regency Romance) http://bookmooch.com/0821775383 #bricked #US #rom
[Mon, 06 Dec 2010 07:04:54 +0000] alexdickson: RT @zerkms: @alexdickson you can do the same with &quot;sql&quot; tag and OMG Ponies :-)
[Mon, 06 Dec 2010 06:59:44 +0000] Symmetricalmoon: @discardoursouls musexualslaves, the ponies are back, and the colourful waters, the cocks and the flowersZZ #gay #yupi
[Mon, 06 Dec 2010 06:56:26 +0000] nurelanwar: DUDE. I AM COMING OVER. WE NEED TO HANG. I'll help you clean :) RT @kamiliatahani: Throwing out my 'my little ponies' :(
[Mon, 06 Dec 2010 06:40:01 +0000] LizziMallory: Holiday TV: Dec. 3: Temecula’s Priceless Ponies invites area children to holiday camp Children will enjoy not ju... http://bit.ly/ecaRMv
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment