Welcome Guest, Not a member yet? Register   Sign In
CI twitter help.
#1

[eluser]Unknown[/eluser]
Hi,
i used this script: http://www.haughin.com/code/twitter/ to get twitter mentions.

I created APP, makes changes in configs how it require.

And have some issue:
script gets mentions good but sometimes i have error:

[code ] => 53 [message] => Basic authentication is not supported

I'm using this code:
Code:
function get_mentions() {
        parse_str($_SERVER['QUERY_STRING'],$_GET);
        $consumer_key = 'B5hbzbM07pnwisb9HeI2ygg';
        $consumer_key_secret = 'jNpo3h6ToChGjgQIy76PURc3az9vvLAsyu49C98va5E';
        $tokens['access_token'] = '176566147-MDdTB9F5bZMd2ugdir67oexkvXzpCBk2BX5yKOYI';
        $tokens['access_token_secret'] = 'U6qPUCkW8ht6fwmsHbIfgA1WnwR7nyhnBMfcPOp6vA';


        $this->load->library('session');



        if ((time() - $this->session->userdata('last_auth')) >= 15) {
            $this->session->set_userdata('last_auth', time());
            //echo ( $this->session->userdata('last_auth'));
            $this->load->library('twitter');

            $auth = $this->twitter->oauth($consumer_key, $consumer_key_secret, $tokens['access_token'], $tokens['access_token_secret']);

            if (isset($auth['access_token']) && isset($auth['access_token_secret'])) {
                // SAVE THE ACCESS TOKENS

                $this->session->set_userdata('twitter_oauth_tokens', $auth);

                if (isset($_GET['oauth_token'])) {
                    $uri = $_SERVER['REQUEST_URI'];
                    $parts = explode('?', $uri);

                    // Now we redirect the user since we've saved their stuff!

                    header('Location: ' . $parts[0]);
                    return;
                }
            }

            $mentions = $this->twitter->call('statuses/mentions', array('count' => 50));
            print_r($mentions);
            if (!isset($mentions->errors)) {
                $fh = fopen($_SERVER['DOCUMENT_ROOT'] . '/mentions.cache', 'w');
                fwrite($fh, json_encode($mentions));
                fclose($fh);
            }
            else {
                $mentions = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/mentions.cache'));
            }
        } else {
            $mentions = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/mentions.cache'));
        }
//        print_R($mentions);
        foreach ($mentions as $mention) {
            echo '<div style="background-color: #222222;font-size: 13px;">';
            echo $mention->user->name . ' wrote: ';
            echo $mention->text;
            echo '</div>';
        }
        die;
    }

Please help me. I need to do this in 2 hours Sad

This action executes by ajax.


Messages In This Thread
CI twitter help. - by El Forum - 10-10-2010, 08:51 AM
CI twitter help. - by El Forum - 10-11-2010, 09:47 AM
CI twitter help. - by El Forum - 12-27-2010, 05:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB