Created
July 2, 2010 03:32
-
-
Save ksz/460891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ExampleController extends AppController | |
{ | |
var $name = 'Example'; | |
var $uses = array(); | |
var $components = array('Twitter' => array('ComsumerKey', | |
'ComsumerSecret')); | |
function index() | |
{ | |
if ($this->Session->check('Twitter.auth')) { | |
$this->redirect('home'); | |
} | |
$this->set('authURL', $this->Twitter->getRequestURL()); | |
} | |
function callback() | |
{ | |
$this->Twitter->getAccessToken(); | |
$this->redirect('home'); | |
} | |
function home() | |
{ | |
if (!$this->Session->check('Twitter.auth')) { | |
$this->redirect('index'); | |
} | |
$auth = $this->Session->read('Twitter.auth'); | |
$this->set('screen_name', $auth['screen_name']); | |
$this->set('timeline', $this->Twitter->getHomeTimeline()); | |
} | |
function logout() | |
{ | |
$this->Session->delete('Twitter.auth'); | |
$this->redirect('index'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment