2011-01-22 12 views
0

私はfollowign curl機能を使って私のcodeigniterページから自動的につぶやきましたが、HTTP応答コード401(not authorized)を取得しています。tweeting to twitter自動的に

コードは次のとおりです。

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