Hi all,
I need help getting all tweets (every single tweet) from one Twitter account using Applescript. Either in xml or text format. I looked on Twitter’s API section to get started and I’ve tried a couple attempts and can’t seem to get it.
Any ideas would be greatly appreciated,
CarbonQuark
Not necessarily using applescript, but in the short term -
- subscribe to the user’s RSS feed for all future tweets.
- go to search.twitter.com - search on the user’s user name. & download the html source for the page into your text editor.
You need to get every tweet just one time? Either way, you’ll have to deal with pagination.
See also: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-user_timeline
thanks guys! your tips led to a solution.
Unfortunately, Twitter limits the amount of requests per hour.
I eventually get this message: “Rate limit exceeded. Clients may not make more than 100 requests per hour.”
I guess I could sign up for multiple accounts and change the user id every 100 requests during script.
Thanks,
CarbonQuark
here is my code (not great but it does what I need) thanks again for the help, CarbonQuark
set userName to "your twitter id goes here"
set userPassword to "your twitter pw goes here"
set myTweets to ""
repeat with x from 1 to 10000
set TwitterUpdate to "/usr/bin/curl" & " --user " & quoted form of (userName & ":" & userPassword) & " [url=http://twitter.com/statuses/user_timeline.rss?page=]http://twitter.com/statuses/user_timeline.rss?page="[/url] & x
set TwitterResponse to do shell script TwitterUpdate as string
if TwitterResponse contains "pubDate" then
set myTweets to myTweets & TwitterResponse
else
exit repeat
end if
end repeat
set text item delimiters to "<title>" & userName & ": "
set myTweets to text items of myTweets
set myTweets to items 2 thru -1 of myTweets
set text item delimiters to "</title>"
repeat with x from 1 to count of myTweets
set item x of myTweets to text item 1 of item x of myTweets
end repeat
set text item delimiters to return
return text items of myTweets as string
May I ask what you’re doing with this? You’ve got me very curious.
BLUEFROG,
Well… I wish I could say something creative or cool…
I made an Applescript based print production tool using Xcode last year and I always wanted to add a log file function to it to keep track of work… then after seeing a post here on posting tweets using applescript it occurred to me that I could use Twitter as a web based log. I just needed a way to pull the log down in order to run stat analysis on it. The code I posted is rough and was just a test.
The guys over at Big Spaceship made this (I think they used Python). Neat idea:
http://www.bigspaceship.com/portfolio/hope-vs-despair
CarbonQuark