如何在推特上從我的網站發佈推文?我正在使用PHP腳本。無論我從我的網站發送的任何推文都應該更新我的Twitter帳戶。我使用下面的代碼,但它不是我的Twitter帳戶更新:如何在推特上使用PHP推文
// Set username and password
$username='myusername';
$password='*********';
// The message you want to send
$message = 'Nice to c all again.Have a nice day..';
// 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, 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);
// check for success or failure
if (empty($buffer)) {
echo 'Try again';
} else {
echo 'success';
}
該腳本返回一個成功的消息,但是當我檢查我的Twitter帳戶沒有推特被發現。
可能是什麼問題?
使用類似'twitter php'的關鍵字的谷歌會扔掉很多鏈接。一些有用的鏈接是:http://dev.twitter.com/pages/libraries#php http://code.google.com/p/php-twitter/您尚未添加腳本。 – thotheolh 2011-01-12 05:49:49