我用下面的代碼來發布更新到Twitter:Twitter的API後被切斷
// Set username and password for twitter API
$username = '***';
$password = '***';
// 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, 10);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$update");
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 'error?!';
}
else
{
// mark the song as tweetered
mysql_query("UPDATE `songs` SET `tweet` = '1' WHERE `id` = $songid ");
}
}
echo $update;
的崗位職能然而,它被切斷出於某種原因。
例如上面的代碼將發佈到:Tiesto - Feel It In My Bones (Feat. Tegan
到twitter。
當要張貼檢查:Tiesto - Feel It In My Bones (Feat. Tegan & Sara) - 160Kbps http://bit.ly/5mdCK4
我使用echo $更新;行末比較輸出到twitter的$update
值和$update
是正確的。
我正在檢查那個權利。我認爲我的代碼以前曾用過&和其他符號,但我正在瀏覽所有帖子。 – ian 2009-10-15 14:45:16
這就是它將重新發布如何正確編碼和感謝。 – ian 2009-10-15 14:46:40
爲什麼轉發?這裏回答。 – ceejayoz 2009-10-15 14:59:34