Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter, Twitter and Oauth..
#1

[eluser]WoolyG[/eluser]
Hi all,

I've been banging my head against this for days now, and simply can't find an easy-to-follow resource on it, and for the life of me, can't get it working.

Has anybody got a simple, easy-to-follow, step by step, guide on how to integrate Twitter's Oauth into my site?


I've loaded Elliot Haughin's CI Library for Twitter & Oauth.

Here's my controller (twitter_call.php):
Code:
<?php

class Twitter_call extends Controller {
    //Could store these in the config etc, up to you
    private $_consumer_key = 'lkdfjvhp9vhpvfndvdf'; // This has been changed, the actual controller has the correct key in there
    private $_consumer_secret = 'lkdfjvhp9vhpvfndvdf'; // This has been changed, the actual controller has the correct secret in there
    private $_access_token = '';  // I'm not sure what to put in here
    private $_secret_access_token = '';  // I'm not sure what to put in here

    function __construct() {
        parent::Controller();
    }

    function index() {
        $this->load->library('twitter');

        $this->twitter->oauth($this->_consumer_key, $this->_consumer_secret, $this->_access_token, $this->_secret_access_token);

           $data['tweets'] = $this->twitter->call('statuses/user_timeline');


        //Load this data into a view and show it.
        $this->load->view('twitter', $data);
    }
}



and here's my view(twitter.php):
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;


&lt;?php print_r($tweets); ?&gt;
&lt;/body&gt;
&lt;/html&gt;



Here's my .htaccess:
Code:
<IfModule mod_rewrite.c>
  

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      
      RewriteRule ^(.*)$ index.php/$1 [L]  
</IfModule>


What I've done too:
Set $config['uri_protocol'] = "PATH_INFO";
Set $config['permitted_uri_chars'] = 'a-z? 0-9~%.:_\-';



Now the problem I'm up against is - when I load http://www.mysite.com/twitter_call, the URL reverts to a login page where I log in to the app. If I re-set my $config['uri_protocol'] to AUTO, the login script for the app works, but I get no joy from the twitter code.

I just want to update my twitter status from this little app behind my site. This is driving me crazy, and my urge to type in capital letters is overwhelming.....! Smile

Can anyone help in a constructive manner? Referring me to Matt Willos site or Elliott Haughins site won't really cut it

I can give someone access to my live code playground if needs be.



All info appreciated - thanks.
WoolyG


Messages In This Thread
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-18-2010, 01:16 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-18-2010, 09:49 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-18-2010, 10:03 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-19-2010, 12:08 AM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-20-2010, 12:30 AM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-21-2010, 09:21 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-22-2010, 10:14 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-22-2010, 10:15 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-22-2010, 11:54 PM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-23-2010, 12:15 AM
CodeIgniter, Twitter and Oauth.. - by El Forum - 09-23-2010, 07:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB