开发者

Tweeting Automatically to twitter

I have used followint curl functionality to tweet automatically from my codeigniter page but I am getting an HTTP responce code 401 (not authorised).

the code is:

var $acc开发者_开发问答ounts_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;
    }
}

Please kindly help me to solve out this issue.

Thanks in advance.


AFAIK, twitter has moved onto OAuth.ie, no more basic authentication.
Read More about OAuth here.
OAuth supported libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜