Created
July 2, 2011 19:13
-
-
Save Zae/1061543 to your computer and use it in GitHub Desktop.
TwitterCake
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 | |
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