五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > 使用PHP同時更新Twitter、飯否、嘀咕和做啥

使用PHP同時更新Twitter、飯否、嘀咕和做啥

文章來源:365jz.com     點擊數(shù):375    更新時間:2009-09-18 10:28   參與評論

在線演示: http://fdszlzl.web.dns12580.com/mblog.php

 

<?php
/*=============================================
Writen by http://cnblogs.com/fdszlzl
===============================================
*/
if(isset($_GET['action']) && $_GET['action']=='post'){
    
$mblog=array(
        
'twitter'=>"http://twitter.com/statuses/update.xml",
        
'fanfou'=>"http://api.fanfou.com/statuses/update.xml",
        
'digu'=>"http://api.digu.com/statuses/update.xml",
        
'zuosa'=>"http://api.zuosa.com/statuses/update.xml"
    );
    
foreach($_POST['m'as $key=>$value){
        
if($key=='digu')
            
$data="content=".urlencode($_POST['data']);
        
else
            
$data="status=".urlencode($_POST['data']);
        
$s=postMblog($mblog[$key],$_POST['username'],$_POST['password'],$data);
        
echo $key.":".getResult($key,$s)."<br/>";
    }
}
function getResult($mblog,$result){
    
$match="";
    
switch($mblog){
        
case "twitter":
        
case "fanfou":
            
$reg="/<error>(.*?)<\/error>/";
            
preg_match($reg,$result,$match);
            
break;
        
case "digu":
            
$reg="/<h3>(.*?)<\/h3>/";
            
preg_match($reg,$result,$match);
            
break;
        
case "zuosa":
            
if($result!='0')
                
$match=array("更新不成功","更新不成功");
            
break;
    }
    
$match=$match?$match[1]:"成功更新";
    
return $match;
}
function postMblog($mblog,$user,$pass,$data){
    
$curl=curl_init();
    curl_setopt(
$curl,CURLOPT_URL,$mblog);
    curl_setopt(
$curl,CURLOPT_USERPWD,$user.":".$pass);
    curl_setopt(
$curl,CURLOPT_RETURNTRANSFER,1);
    curl_setopt(
$curl,CURLOPT_POSTFIELDS,$data);
    
$s=curl_exec($curl);
    curl_close(
$curl);
    
return $s;
}

?>
<form method="post" name="mblog" action="?action=post">
<textarea name="data" maxlength="140" rows="6" cols="60"></textarea><br/>
用戶名:
<input name="username" /><br/>
&nbsp;&nbsp;碼:<input name="password" type="password"/><br/>
<input type="checkbox"  name="m[twitter]" value="1" checked="checked"/> Twitter 
<input type="checkbox" name="m[fanfou]" value="1" checked="checked"/> 飯否 
<input type="checkbox" name="m[digu]" value="1" checked="checked"/> 嘀咕 
<input type="checkbox" name="m[zuosa]" value="1" checked="checked"/> 做啥
<br/><br/>
<input type="submit" value=" 發(fā) 布 "/>
</form>

 

收藏與分享
Tag標簽: 微博客

如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答!! 點擊進入論壇

發(fā)表評論 (375人查看,0條評論)
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學習

業(yè)務咨詢

· 技術(shù)支持
· 服務時間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號