Skip to content

Instantly share code, notes, and snippets.

@ksz
Created July 2, 2010 03:32
Show Gist options
  • Save ksz/460891 to your computer and use it in GitHub Desktop.
Save ksz/460891 to your computer and use it in GitHub Desktop.
<?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