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.
#2

[eluser].giorgio[/eluser]
first of all: ERASE YOUR CONSUMER KEY AND SECRET AND GET SOME NEW AT TWITTER, anyone who reads this post kan now authenticate as your app and fuck things up...

the basic authentication method is deprecated by twitter and cannot be used anymore. If you need to authenticate your app, use the oauth method.

btw: to retrieve public tweets, mentions, public timeline, or anything like that, you don't need to authenticate at all! authentication is only needed if you want to post something on a users wall

also note that the twitter search url has been changed to http://search.twitter.com/search, change it in the twitter library source.
#3

[eluser]Unknown[/eluser]
[quote author=".giorgio" date="1286830053"]fi

btw: to retrieve public tweets, mentions, public timeline, or anything like that, you don't need to authenticate at all! authentication is only needed if you want to post something on a users wall

I tried this one and get the message :
"Basic authentication is not supported"

Someone help?




Theme © iAndrew 2016 - Forum software by © MyBB