Earlier today I decided to clear out all of my existing tweets and start over again.  After looking around for a bit on Twitter, I saw that my options were to either delete my account entirely (and lose all of my contacts) or delete all of my tweets one by one.  Neither one of these was an acceptable solution to the problem, so I took two minutes to do it in CF.

I know this is really only useful in somewhat rare circumstances, but if you need it, now you have something to copy / paste.

<cfhttp method="GET" url="http://twitter.com/statuses/user_timeline/foo.xml?count=200" username="foo" password="blarg" />
<cfset theList = xmlParse(cfhttp.fileContent) />
<cfset loopCount = arrayLen(theList.statuses.status) />
 
<cfloop from="1" to="#loopCount#" index="i">
	<cfhttp method="post" url="http://twitter.com/statuses/destroy.xml" username="foo" password="blarg">
		<cfhttpparam type="formField" name="id" value="#theList.statuses.status[i].id.xmlText#" />
	</cfhttp>
</cfloop>

Just change ‘foo’ to your Twitter username and ‘blarg’ to your Twitter password and all should be good. As it stands this will run through and delete 200 tweets each time the script is executed. You could always enclose the whole thing in another loop that keeps going until you’re all wiped out if you want.

Also, this takes longer than 60 seconds to run, so if you have a 60 second execution timeout on your server it’s going to throw an exception. Either way, it saved me a metric assload of time this morning.

UPDATE: In the time since this was posted, Twitter has switched to requiring OAuth for all API calls, which means this will not work any longer. Hopefully it was helpful to a person or two while it worked.