
I came across a problem of how to send my wordpress post directly to twitter using Curl, and after my several tries i found this solution. You can use this as plugin as well in wordpress by saving this code in wp-content/plugins directory. Make sure you add your twitter credentials in the code before activating this plugin.
Here goes the code:
$twitter_username = “your username”;
$twitter_password = “your password”;
$post_title = get_the_title($post_ID);
$permalink = get_permalink($post_ID);
$tw_title = substr($post_title, 0,70);
$message = “$tw_title $permalink”;
// The twitter API address
$url = ‘http://twitter.com/statuses/update.xml’;
// Set up and execute the curl process
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, “$url”);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, “status=$message”);
curl_setopt($curl_handle, CURLOPT_USERPWD, “$twitter_username:$twitter_password”);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
I also made the plugin for delicious, diigo and tumblr. If you want the plugin you can contact me at vickytechno@yahoo.com
This plugin lets you auto post to all these social networks via curl and also take care of SSL