Post to Twitter PHP Function (915 bytes, 308 hits)
Looking to Tweet from PHP? This little function will do exactly that. Simply supply a username, password and Tweet, and thanks to CURLs black magic your message will be Tweeted. You can also specify which format you would like the response in – either JSON or XML, with JSON being the default.
<? function tweet($username, $pword, $status, $format='json') {
$ch = curl_init(); // init curl
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/update.".$format);
curl_setopt($ch, CURLOPT_POSTFIELDS, "status=$status");
curl_setopt($ch, CURLOPT_USERPWD, "$username:$pword");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$bf = curl_exec($ch); // execute curl call
curl_close($ch); // close curl handler
// Return true or false demending on results
return $bf;
} ?>
Using the PHP to Twitter function
echo tweet('TwitterUSERNAME','Password','Rocking the PHP-To-Twitter function by @brandoncorbin');
Post to Twitter PHP Function (915 bytes, 308 hits)



Post to Twitter from PHP with this super simple function – http://bit.ly/bCUu2n
Post to Twitter from PHP with this super simple function – http://bit.ly/bCUu2n
@bang590 底下还有一个错误:
Fatal error: Call to undefined function curl_init() in www/t/lib/twitter.php on line 775
@Showfom 你好,我在使用twiteseV1.3的时候提示lib/lib/twitter.php on line 832 Fatal error: Call to undefined function: json_decode() in 有有什么解决之法吗
Phooey. http://educon22.org = “Fatal error: Call to undefined function apc_fetch() in /var/mics/code/Plugins/functions/twitter.php line 9″ ?
fuck you all
And fuck you too, good man.
This will fail from mid-August, when Twitter mandates oAuth.