Skip to content

Instantly share code, notes, and snippets.

@Zae
Created July 2, 2011 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zae/1061543 to your computer and use it in GitHub Desktop.
Save Zae/1061543 to your computer and use it in GitHub Desktop.
TwitterCake
<?php
App::import('Lib', 'Twitteroauth.Twitteroauth');
class TwitterCake extends TwitterOAuth{
public $configs = array();
public function __construct($oauth_token = NULL, $oauth_token_secret = NULL, $consumer_key = NULL, $consumer_secret = NULL) {
if($consumer_key === NULL){
$consumer_key = $this->getConfig('consumerKey');
}
if($consumer_secret === NULL){
$consumer_secret = $this->getConfig('consumerSecret');
}
if($oauth_token === NULL){
$oauth_token = $this->getConfig('oauthToken');
}
if($oauth_token_secret === NULL){
$oauth_token_secret = $this->getConfig('oauthTokenSecret');
}
parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
}
/**
* Testing getting a configuration option.
* @param key to search for
* @return mixed result of configuration key.
* @access public
*/
private function getConfig($key = null){
if(isset($this->configs[$key])){
return $this->configs[$key];
}
//try configure setting
if($this->configs[$key] = Configure::read("Twitter.$key")){
return $this->configs[$key];
}
//try load configuration file and try again.
Configure::load('twitter');
$this->configs = Configure::read('Twitter');
if($this->configs[$key] = Configure::read("Twitter.$key")){
return $this->configs[$key];
}
return null;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment