Hi Coders,

I recently found a script online that clears tweets from a twitter account. The script is written in coldfusion which is not supported by most web hosts as you guys know. I'm a programming newbie, so I want to know if it's possible to code this same script in php so that it will work on my current hosts server. The code looks simple enough.

Here is the code below:

<cfhttp method="GET" url="http://twitter.com/statuses/user_timeline/foo.xml?count=2000" username="username" password="password" />
<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="username" password="password">
		<cfhttpparam type="formField" name="id" value="#theList.statuses.status[i].id.xmlText#" />
	</cfhttp>
</cfloop>

Recommended Answers

All 3 Replies

I think you can use cURL to do that, you may change this script to make it work fine, it's just an example:

//retrieve data
$curl = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'http://twitter.com/statuses/user_timeline/foo.xml?count=2000');
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$xmlRaw = curl_exec($curl);
curl_close($curl);

//convert data
$xmlr = new SimpleXMLElement($xmlRaw);

//delete data loop
foreach($xmlr as $row)
{
$delete = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'http://twitter.com/statuses/destroy.xml');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $row->id);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_exec($delete);
curl_close($delete);
}

More info on cURL library: http://www.php.net/manual/en/book.curl.php

THANKS for the reply, I am still a student when it comes to this stuff. I will look into cURL. thanks for the advice.

PHP Contact Importer Library:

* PHP 4 or 5
* cURL 7.1 or higher (compiled with OpenSSL and zlib).

PHP source code is not encrypted. You will get all lines of the code. When a webmail changes then we have to update our importer, we update that webmail's contact importer engine and send that to our clients. If hotmail.com changes then we update hotmail.php and send that. That's why we don't recommend that you to change the code for hotmai.php/gmai.php/yahoo.php or aol.php. You will receive six month's worth of free updates after purchasing Contact Importer.

http://www.improsys.com/importer.htm

you may check right now...
http://www.improsys.com/contacts/index.php
http://www.improsys.com/contacts/index2.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.