I use the below code to post updates to twitter:
// Set username and password for twitter API
$username = '***';
$password = '***';
// The twitter API address
$url = 'http://twitter.com/statuses/update.xml';
// Alternative JSON version
// $url = 'http://twitter.com/statuses/update.json';
// Set up and execute the curl process
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$update");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
// check for success or failure
if (empty($buffer))
{
echo 'error?!';
}
else
{
// mark the song as tweetered
mysql_query("UPDATE `songs` SET `tweet` = '1' WHERE `id` = $songid ");
}
}
echo $update;
The post functions however it is cut off for some reason.
For example the above code will post: Tiesto - Feel It In My Bones (Feat. Tegan
to twitter.
When it should post: Tiesto - Feel It In My Bones (Feat. Tegan & Sara) - 160Kbps http://bit.ly/5mdCK4
I use the echo $update; line at the end compare the output to twitter to the $update
value and $update
is correct.