【发布时间】:2011-07-17 16:23:49
【问题描述】:
我在通过用户名和密码更新 Twitter 状态时遇到问题。
这是代码:
$username = 'username';
$password = 'password';
$message = 'Testing';
$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_HTTPAUTH, CURLAUTH_BASIC); //basic authentication
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);
echo $buffer;
这不仅适用于一个用户,因此我不能使用 OAuth(意味着使用消费者密钥和其他令牌)。我已经尝试过:http://www.1stwebdesigner.com/tutorials/how-to-update-twitter-using-php-and-twitter-api/ 但我无法传递多个用户的用户名和密码来更新多个 Twitter 状态。
请帮帮我。
【问题讨论】: