Easiest way to send tweet to Twitter with Php

.

Twitter is all around us.
People are tweet to the friends , colleagues, client and to the world.
Php provide in built function which allow to send tweet to you twitter account without any need of third party library .
Below is the code in php that will allow the functionality.

array(
    'method'  => 'POST',
    'header'  => sprintf("Authorization: Basic %s\r\n", base64_encode($username.':'.$password)).
                 "Content-type: application/x-www-form-urlencoded\r\n",
    'content' => http_build_query(array('status' => $message)),
    'timeout' => 5,
  ),
));
$ret = file_get_contents('http://twitter.com/statuses/update.xml', false, $context);

return false !== $ret;
}

tweet('From PHP, yeah...', 'userName', 'passwordxxxx');

?>


Where in function
tweet('From PHP, yeah...', 'userName', 'passwordxxxx');
userName = your twitter username
passwordxxx = your twitter account password

Link to the orginal post : Original post



1 comments:

Andy said...

How about code to tweet someone else from a php based web site? Tweet, instead of clicking on an email URL?

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment