Welcome Guest, Not a member yet? Register   Sign In
Haughin’s Twitter Library - Accessing the current user's username.
#10

[eluser]clayko[/eluser]
My controller code (most of it... not the code to load the view, etc)

Code:
$consumer_key = 'MY KEY';
            $consumer_key_secret = 'MY KEY'
            // For this example, we're going to get and save our access_token and access_token_secret
            // in session data, but you might want to use a database instead :)

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

            $tokens['access_token'] = NULL;
            $tokens['access_token_secret'] = NULL;

            // GET THE ACCESS TOKENSin
            

            $oauth_tokens = $this->session->userdata('twitter_oauth_tokens');

            if ( $oauth_tokens !== FALSE ) $tokens = $oauth_tokens;

            $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);
                
                        list($id, $code) = explode("-",  $auth['access_token']);
                        $this->session->set_userdata('id', $id);
                
                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;
                }
            }

            // This is where  you can call a method.
            $id = $this->session->userdata('id');

            
            $user_info = $this->twitter->call('users/show', array('id' => $id));
            
        
               $data['name'] = $user_info->name;
            
            echo $data['name'];

THE ERROR:

Code:
Message: Undefined property: stdClass::$name
Filename: controllers/test.php
Line Number: 224

Line 224: $data['name'] = $user_info->name;


Messages In This Thread
Haughin’s Twitter Library - Accessing the current user's username. - by El Forum - 05-26-2010, 05:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB