Code archives/Networking/Access Twitter Search API

This code has been declared by its author to be Public Domain code.

Download source code

Access Twitter Search API by Loktar2009
Quick simple way to pull the latest tweets based on a specific search query.
; This gets the latest 15 tweets based on the keyword. You can also pass rpp= to get 
; up to 100 results, and * to get pages, example "GET /search.atom?q=" + keyword$ + "&rpp=100*5" 

Graphics3D 640,480, 0 ,2
Dim Tweets$(100)

getTweets("blitz")

WaitKey

Function getTweets(keyword$)
	tcp = OpenTCPStream("search.twitter.com", 80)

	If Not tcp Print "Failed.":WaitKey:End


	WriteLine tcp, "GET /search.atom?q=" + keyword$
	WriteLine tcp, "HOST: search.twitter.com"

	If Eof(tcp) Print "Failed.":WaitKey:End

	While Not Eof(tcp)
		currentTweet$ = Trim(ReadLine$(tcp))	
		If Left(currentTweet$, 7) = "<title>" Then
			Tweets$(i) = Mid(currentTweet$, 8, Len(currentTweet$) -15)
			Print Tweets$(i)
		End If 
	Wend

	If Eof(tcp)<>1 Then Print "Error!"

	CloseTCPStream tcp
End Function

Comments

Heliotrope2009
what does getTweets do?


Guy Fawkes2009
it's your twitter account dude. lol


Ked2010
No.

It prints out all the tweets with the passed keyword.


Code Archives Forum