嘀咕、搜狐微博也有开放API,但似乎没有像样的OAuth(可能是我没有找到),下面是使用php curl利用嘀咕、搜狐微博API发布微博的例子,具体代码如下:
$username = 'haibor';
$password = 'password';
$content='诺豆网日志同步至嘀咕搜狐微博';
// 搜狐 Sohu API
$url = 'http://api.t.sohu.com/statuses/update.xml';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_POSTFIELDS,'status='.urlencode($content)) ;
curl_setopt($curl, CURLOPT_HEADER, 0);//1显示头,0不显示头。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//禁止返回status的状态。
curl_exec($curl);
curl_close($curl);
// 嘀咕 Digu API
$url = 'http://api.minicloud.com.cn/statuses/update.format';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_POSTFIELDS,'content='.urlencode('sorry for emlog')) ;
curl_setopt($curl, CURLOPT_HEADER, 0);//1显示头,0不显示头。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//禁止返回status的状态。
curl_exec($curl);
curl_close($curl);
?>