2011-01-22 74 views
0

我已經使用followint捲曲功能從我的codeigniter頁面自動發送推文,但我得到一個HTTP響應代碼401(未經授權)。Tweeting自動推特

代碼:

var $accounts_table = 'accounts'; 
var $update_url = 'http://twitter.com/statuses/update.xml'; 

function update_status($username, $password, $message) 
{ 
    $ch = curl_init($this->update_url); 

    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'status='.urlencode($message)); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_USERPWD, $username .':'.$password); 

    curl_exec($ch); 

    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    echo $httpcode; 
    // if we were successfull we need to update our last_message 
    if ($httpcode == '200') 
    { 
     $this->db->where('active', '1'); 
     $this->db->update($this->accounts_table, array('last_message' => $message)); 

     return TRUE; 
    } 

    else 
    { 
     return FALSE; 
    } 
} 

煩請幫我解決了這個問題。

在此先感謝。

回答

1

AFAIK,twitter已轉移到OAuth.ie上,沒有更多的基本認證。
瞭解有關OAuth的更多信息here
OAuth支持libraries