10 defined(
'JPATH_PLATFORM') or die();
40 $this->options = isset($options) ? $options :
new JRegistry;
42 $this->options->
def(
'accessTokenURL',
'https://api.twitter.com/oauth/access_token');
43 $this->options->def(
'authenticateURL',
'https://api.twitter.com/oauth/authenticate');
44 $this->options->def(
'authoriseURL',
'https://api.twitter.com/oauth/authorize');
45 $this->options->def(
'requestTokenURL',
'https://api.twitter.com/oauth/request_token');
48 parent::__construct($this->options, $client, $input, $application);
58 public function verifyCredentials()
60 $token = $this->getToken();
63 $parameters = array(
'oauth_token' => $token[
'key']);
66 $path =
'https://api.twitter.com/1.1/account/verify_credentials.json';
69 $response = $this->oauthRequest($path,
'GET', $parameters);
72 if ($response->code == 200)
89 public function endSession()
91 $token = $this->getToken();
94 $parameters = array(
'oauth_token' => $token[
'key']);
97 $path =
'https://api.twitter.com/1.1/account/end_session.json';
100 $response = $this->oauthRequest($path,
'POST', $parameters);
102 return json_decode($response->body);
116 public function validateResponse($url, $response)
118 if (strpos($url,
'verify_credentials') ===
false && $response->code != 200)
120 $error = json_decode($response->body);
122 if (property_exists($error,
'error'))
124 throw new DomainException($error->error);
128 $error = $error->errors;
129 throw new DomainException($error[0]->message, $error[0]->code);