Automatic twitter plugin- using youruls but changed to php code
-
Hi all
I have been using the yoururls twitter plugin but it doesn’t seem to be working so I changed to using this code but it also doesn’t seem to do the job. What is a good plugin or why doesn;t this code work? Thanks:function twitterUpdate($postTitle, $postLink, $isNew) { // Enter Your Twitter ID Here $username = 'xxxxxxx'; // Enter Your Twitter Password Here $password = 'xxxxxxx'; # text into a twitter friendly text $code_entities_match = array('--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','‘,’=’);
$code_entities_replace = array(‘-‘,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”,”);
$postTitle = str_replace($code_entities_match, $code_entities_replace, $postTitle);// Check if New or Updated Post
if($isNew)
$postTitle = ‘New Post: ‘ . $postTitle;
else
$postTitle = ‘Updated Post: ‘ . $postTitle;// Calculate Twitter Msg and keep it under 140 Chars
if(strlen ($postTitle) > (140 – strlen ($postLink)))
$postTitle = substr_replace($postTitle, ‘…’, (140 – 3 – strlen ($postLink)));$message = $postTitle . $postLink;
// The twitter API address
$url = ‘http://twitter.com/statuses/update.xml’;
$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, “$username:$password”);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);// Uncomment the lines below to check if
// CURL is enabled on your Web Server
// check for success or failure/* if (empty($buffer))
echo ‘message’;
else
echo ‘success’;
*/
}`
The topic ‘Automatic twitter plugin- using youruls but changed to php code’ is closed to new replies.