public function initialize($key, $secret) { // Check the public key if (!is_string($key) || strlen($key) !== 22) { return OAuth()->raise('Invalid twitter key "' . $key . '"', E_USER_WARNING); } // Check the private key if (!is_string($secret) || strlen($secret) !== 40) { return OAuth()->raise('Invalid twitter secret "' . $secret . '"', E_USER_WARNING); } // Set data $this->key = $key; $this->secret = $secret; // Initialize $this->twitter = new Twitter(array('app_id' => $key, 'secret' => $secret)); }
public function api($cmd, $params = array(), $method = 'GET') { if (!is_string($method)) { OAuth()->raise('Invalid method given'); } $method = strtolower($method); $result = $this->twitter->{$method}($cmd, $params); if (isset($result->error)) { OAuth()->raise($result->error); } return $result; }