利用DIGU api发布信息
作者:admin 日期:2010-07-26
利用DIGU api发布信息
PHP代码
- <?php
- function digu($content)
- {
- $url = 'http://api.minicloud.com.cn/statuses/update.xml' ;
- $fields = array(
- 'content'=>urlencode($content) ,
- );
- foreach($fields as $key=>$value)
- { $fields_string .= $key.'='.$value.'&' ; }
- rtrim($fields_string ,'&') ;
- $ch = curl_init() ;
- curl_setopt($ch, CURLOPT_URL,$url) ;
- curl_setopt($ch, CURLOPT_USERPWD, "user@domain.com:yourpass");
- curl_setopt($ch, CURLOPT_POST,count($fields)) ;
- curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string) ;
- $result = curl_ex ec($ch) ; //注意删除这里的空格ex跟ec之间
- curl_close($ch) ;
- }
- echo digu('这个是用curl编写的PHP程序通过diguAPI发布的!');
- ?>







