Completed
Push — master ( 369c90...324e29 )
by Michael
04:57
created
plugins/actions/twitter/Twitter.class.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,70 +6,70 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 if (class_exists('Twitter')) {
9
-    return true;
9
+	return true;
10 10
 }
11 11
 
12 12
 class Twitter
13 13
 {
14 14
 
15
-    private $auth  = false;
16
-    private $debug = false;
17
-    public  $error = false;
15
+	private $auth  = false;
16
+	private $debug = false;
17
+	public  $error = false;
18 18
 
19
-    function __construct($user, $pass, $debug = false)
20
-    {
21
-        // Store an auth key for the HTTP Authorization: header
22
-        $this->auth  = base64_encode($user . ':' . $pass);
23
-        $this->debug = $debug;
24
-    }
19
+	function __construct($user, $pass, $debug = false)
20
+	{
21
+		// Store an auth key for the HTTP Authorization: header
22
+		$this->auth  = base64_encode($user . ':' . $pass);
23
+		$this->debug = $debug;
24
+	}
25 25
 
26
-    function update($new_status)
27
-    {
28
-        if (strlen($new_status) > 140) {
29
-            $this->error = "Status too long: {$new_status}.";
30
-            return false;
31
-        }
32
-        $fp = @fsockopen('twitter.com', 80, $errno, $errstr);
33
-        if (!$fp) {
34
-            $this->error = "Socket error #{$errno}: {$errstr}";
35
-            return false;
36
-        }
37
-        $post_data = 'status=' . urlencode($new_status);
38
-        $to_send   = "POST /statuses/update.xml HTTP/1.1\r\n";
39
-        $to_send .= "Host: twitter.com\r\n";
40
-        $to_send .= 'Content-Length: ' . strlen($post_data) . "\r\n";
41
-        $to_send .= "Authorization: Basic {$this->auth}\r\n\r\n";
42
-        $to_send .= $post_data . "\r\n\r\n";
43
-        $bytes = fwrite($fp, $to_send);
44
-        if ($bytes === false) {
45
-            $this->error = 'Socket error: Error sending data.';
46
-            return false;
47
-        } elseif ($bytes < strlen($to_send)) {
48
-            $this->error = 'Socket error: Could not send all data.';
49
-            return false;
50
-        }
51
-        if ($this->debug) echo "Sent:\n{$to_send}\n\n";
52
-        $response = '';
53
-        while (!feof($fp)) {
54
-            $buf = fread($fp, 1024);
55
-            if ($buf === false) {
56
-                $this->error = 'Socket error: Error reading data.';
57
-                return false;
58
-            }
59
-            $response .= $buf;
60
-        }
61
-        if ($this->debug) echo "Received:\n{$response}";
62
-        $was_error = preg_match('#' . preg_quote('<error>') . '(.+)' . preg_quote('</error>') . '#i', $response, $matches);
63
-        if ($was_error) {
64
-            $this->error = "Twitter error: {$matches[1]}";
65
-            return false;
66
-        }
67
-        list($first_line) = explode("\r\n", $response);
68
-        if ($first_line !== 'HTTP/1.1 200 OK') {
69
-            $this->error = "Request error: {$first_line}";
70
-            return false;
71
-        }
72
-        return true;
73
-    }
26
+	function update($new_status)
27
+	{
28
+		if (strlen($new_status) > 140) {
29
+			$this->error = "Status too long: {$new_status}.";
30
+			return false;
31
+		}
32
+		$fp = @fsockopen('twitter.com', 80, $errno, $errstr);
33
+		if (!$fp) {
34
+			$this->error = "Socket error #{$errno}: {$errstr}";
35
+			return false;
36
+		}
37
+		$post_data = 'status=' . urlencode($new_status);
38
+		$to_send   = "POST /statuses/update.xml HTTP/1.1\r\n";
39
+		$to_send .= "Host: twitter.com\r\n";
40
+		$to_send .= 'Content-Length: ' . strlen($post_data) . "\r\n";
41
+		$to_send .= "Authorization: Basic {$this->auth}\r\n\r\n";
42
+		$to_send .= $post_data . "\r\n\r\n";
43
+		$bytes = fwrite($fp, $to_send);
44
+		if ($bytes === false) {
45
+			$this->error = 'Socket error: Error sending data.';
46
+			return false;
47
+		} elseif ($bytes < strlen($to_send)) {
48
+			$this->error = 'Socket error: Could not send all data.';
49
+			return false;
50
+		}
51
+		if ($this->debug) echo "Sent:\n{$to_send}\n\n";
52
+		$response = '';
53
+		while (!feof($fp)) {
54
+			$buf = fread($fp, 1024);
55
+			if ($buf === false) {
56
+				$this->error = 'Socket error: Error reading data.';
57
+				return false;
58
+			}
59
+			$response .= $buf;
60
+		}
61
+		if ($this->debug) echo "Received:\n{$response}";
62
+		$was_error = preg_match('#' . preg_quote('<error>') . '(.+)' . preg_quote('</error>') . '#i', $response, $matches);
63
+		if ($was_error) {
64
+			$this->error = "Twitter error: {$matches[1]}";
65
+			return false;
66
+		}
67
+		list($first_line) = explode("\r\n", $response);
68
+		if ($first_line !== 'HTTP/1.1 200 OK') {
69
+			$this->error = "Request error: {$first_line}";
70
+			return false;
71
+		}
72
+		return true;
73
+	}
74 74
 
75 75
 }
Please login to merge, or discard this patch.
plugins/actions/twitter/bitly.class.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -13,218 +13,218 @@
 block discarded – undo
13 13
 */
14 14
 
15 15
 if (class_exists('Bitly')) {
16
-    return true;
16
+	return true;
17 17
 }
18 18
 
19 19
 class Bitly
20 20
 {
21 21
 
22
-    protected $api          = 'http://api.bit.ly/';
23
-    private   $format       = 'json';
24
-    private   $version      = '2.0.1';
25
-    private   $validActions = array(
26
-        'shorten',
27
-        'stats',
28
-        'info',
29
-        'expand'
30
-    );
31
-
32
-    public function __construct($login, $apiKey)
33
-    {
34
-        $this->login        = $login;
35
-        $this->apiKey       = $apiKey;
36
-        $this->statusCode   = 'OK';
37
-        $this->errorMessage = '';
38
-        $this->errorCode    = '';
39
-        return true;
40
-    }
41
-
42
-    private function setError($message, $code = 101)
43
-    {
44
-        $this->errorCode    = $code;
45
-        $this->errorMessage = $message;
46
-        $this->statusCode   = 'ERROR';
47
-    }
48
-
49
-    public function validAction($action)
50
-    {
51
-        if (in_array($action, $this->validActions)) {
52
-            return true;
53
-        }
54
-        $this->setError("Undefined method $action", 202);
55
-        return false;
56
-    }
57
-
58
-    public function error()
59
-    {
60
-        $ret = array(
61
-            'errorCode'    => $this->errorCode,
62
-            'errorMessage' => $this->errorMessage,
63
-            'statusCode'   => $this->statusCode
64
-        );
65
-
66
-        // Function used for passing empty result sometimes.
67
-        if ($this->statusCode === 'OK') {
68
-            $ret['results'] = array();
69
-        }
70
-        if ($this->format === 'json') {
71
-            return json_encode($ret);
72
-        } else {
73
-            throw new Exception('Unsupported format');
74
-        }
75
-    }
76
-
77
-    public function shorten($message)
78
-    {
79
-
80
-        $postFields = '';
81
-        preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
82
-
83
-        for ($i = 0; $i < count($matches[0]); $i++) {
84
-            $curr = $matches[0][$i];
85
-            // ignore bitly urls
86
-            if (!strstr($curr, 'http://bit.ly')) {
87
-                $postFields .= '&longUrl=' . urlencode($curr);
88
-            }
89
-        }
90
-
91
-        // nothing to shorten, return empty result
92
-        if (!strlen($postFields)) {
93
-            return $this->error();
94
-        }
95
-        return $this->process('shorten', $postFields);
96
-    }
97
-
98
-    public function expand($message)
99
-    {
100
-        $postFields = '&hash=' . $this->getHash($message);
101
-        return $this->process('expand', $postFields);
102
-    }
103
-
104
-    public function info($bitlyUrl)
105
-    {
106
-        $hash       = $this->getHash($bitlyUrl);
107
-        $postFields = '&hash=' . $hash;
108
-        return $this->process('info', $postFields);
109
-    }
110
-
111
-    public function stats($bitlyUrl)
112
-    {
113
-        // Take only first hash or url. Ignore others.
114
-        $a          = split(',', $bitlyUrl);
115
-        $postFields = '&hash=' . $this->getHash($a[0]);
116
-        return $this->process('stats', $postFields);
117
-    }
118
-
119
-    protected function process($action, $postFields)
120
-    {
121
-        $ch = curl_init($this->api . $action);
122
-
123
-        $postFields = 'version=' . $this->version . $postFields;
124
-        $postFields .= '&format=' . $this->format;
125
-        $postFields .= '&history=1';
126
-
127
-        curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
128
-        curl_setopt($ch, CURLOPT_POST, 1);
129
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
130
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
131
-
132
-        $response = curl_exec($ch);
133
-
134
-        curl_close($ch);
135
-
136
-        return $response;
137
-    }
138
-
139
-    public function setReturnFormat($format)
140
-    {
141
-        // needed for restoration
142
-        $this->oldFormat = $this->format;
143
-        $this->format    = $format;
144
-        return $this->format;
145
-    }
146
-
147
-    private function restoreFormat()
148
-    {
149
-        if (!empty($this->oldFormat)) {
150
-            $this->format = $this->oldFormat;
151
-        }
152
-        return $this->format;
153
-    }
154
-
155
-    // expect url, shortened url or hash
156
-    public function getHash($message)
157
-    {
158
-        // if url and not bit.ly get shortened first
159
-        if (strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
160
-            $message = $this->shortenSingle($message);
161
-        }
162
-        $hash = str_replace('http://bit.ly/', '', $message);
163
-        return $hash;
164
-    }
165
-
166
-    public function shortenSingle($message)
167
-    {
168
-        $this->setReturnFormat('json');
169
-        $data = json_decode($this->shorten($message), true);
170
-        // return to previous state.
171
-        $this->restoreFormat();
172
-
173
-        // replace every long url with short one
174
-        foreach ($data['results'] as $url => $d) {
175
-            $message = str_replace($url, $d['shortUrl'], $message);
176
-        }
177
-        return $message;
178
-    }
179
-
180
-    public function expandSingle($shortUrl)
181
-    {
182
-        $this->setReturnFormat('json');
183
-        $data = json_decode($this->expand($shortUrl), true);
184
-        $this->restoreFormat();
185
-        return $data['results'][$this->getHash($shortUrl)]['longUrl'];
186
-    }
187
-
188
-    public function getInfoArray($url)
189
-    {
190
-        $this->setReturnFormat('json');
191
-        $json = $this->info($url);
192
-        $this->restoreFormat();
193
-        $data = json_decode($json, true);
194
-
195
-        $this->infoArray = array_pop($data['results']);
196
-        return $this->infoArray;
197
-    }
198
-
199
-    public function getStatsArray($url)
200
-    {
201
-        $this->setReturnFormat('json');
202
-        $json = $this->stats($url);
203
-        $this->restoreFormat();
204
-        $data             = json_decode($json, true);
205
-        $this->statsArray = $data['results'];
206
-        return $this->statsArray;
207
-    }
208
-
209
-    public function getClicks()
210
-    {
211
-        return $this->statsArray['clicks'];
212
-    }
213
-
214
-    // get thumbnail (small, middle, large)
215
-    public function getThumbnail($size = 'small')
216
-    {
217
-        if (!in_array($size, array('small', 'medium', 'large'))) {
218
-            throw new Exception('Invalid size value');
219
-        }
220
-        if (empty($this->infoArray)) {
221
-            throw new Exception('Info not loaded');
222
-        }
223
-        return $this->infoArray['thumbnail'][$size];
224
-    }
225
-
226
-    public function getTitle()
227
-    {
228
-        return $this->infoArray['htmlTitle'];
229
-    }
22
+	protected $api          = 'http://api.bit.ly/';
23
+	private   $format       = 'json';
24
+	private   $version      = '2.0.1';
25
+	private   $validActions = array(
26
+		'shorten',
27
+		'stats',
28
+		'info',
29
+		'expand'
30
+	);
31
+
32
+	public function __construct($login, $apiKey)
33
+	{
34
+		$this->login        = $login;
35
+		$this->apiKey       = $apiKey;
36
+		$this->statusCode   = 'OK';
37
+		$this->errorMessage = '';
38
+		$this->errorCode    = '';
39
+		return true;
40
+	}
41
+
42
+	private function setError($message, $code = 101)
43
+	{
44
+		$this->errorCode    = $code;
45
+		$this->errorMessage = $message;
46
+		$this->statusCode   = 'ERROR';
47
+	}
48
+
49
+	public function validAction($action)
50
+	{
51
+		if (in_array($action, $this->validActions)) {
52
+			return true;
53
+		}
54
+		$this->setError("Undefined method $action", 202);
55
+		return false;
56
+	}
57
+
58
+	public function error()
59
+	{
60
+		$ret = array(
61
+			'errorCode'    => $this->errorCode,
62
+			'errorMessage' => $this->errorMessage,
63
+			'statusCode'   => $this->statusCode
64
+		);
65
+
66
+		// Function used for passing empty result sometimes.
67
+		if ($this->statusCode === 'OK') {
68
+			$ret['results'] = array();
69
+		}
70
+		if ($this->format === 'json') {
71
+			return json_encode($ret);
72
+		} else {
73
+			throw new Exception('Unsupported format');
74
+		}
75
+	}
76
+
77
+	public function shorten($message)
78
+	{
79
+
80
+		$postFields = '';
81
+		preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
82
+
83
+		for ($i = 0; $i < count($matches[0]); $i++) {
84
+			$curr = $matches[0][$i];
85
+			// ignore bitly urls
86
+			if (!strstr($curr, 'http://bit.ly')) {
87
+				$postFields .= '&longUrl=' . urlencode($curr);
88
+			}
89
+		}
90
+
91
+		// nothing to shorten, return empty result
92
+		if (!strlen($postFields)) {
93
+			return $this->error();
94
+		}
95
+		return $this->process('shorten', $postFields);
96
+	}
97
+
98
+	public function expand($message)
99
+	{
100
+		$postFields = '&hash=' . $this->getHash($message);
101
+		return $this->process('expand', $postFields);
102
+	}
103
+
104
+	public function info($bitlyUrl)
105
+	{
106
+		$hash       = $this->getHash($bitlyUrl);
107
+		$postFields = '&hash=' . $hash;
108
+		return $this->process('info', $postFields);
109
+	}
110
+
111
+	public function stats($bitlyUrl)
112
+	{
113
+		// Take only first hash or url. Ignore others.
114
+		$a          = split(',', $bitlyUrl);
115
+		$postFields = '&hash=' . $this->getHash($a[0]);
116
+		return $this->process('stats', $postFields);
117
+	}
118
+
119
+	protected function process($action, $postFields)
120
+	{
121
+		$ch = curl_init($this->api . $action);
122
+
123
+		$postFields = 'version=' . $this->version . $postFields;
124
+		$postFields .= '&format=' . $this->format;
125
+		$postFields .= '&history=1';
126
+
127
+		curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
128
+		curl_setopt($ch, CURLOPT_POST, 1);
129
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
130
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
131
+
132
+		$response = curl_exec($ch);
133
+
134
+		curl_close($ch);
135
+
136
+		return $response;
137
+	}
138
+
139
+	public function setReturnFormat($format)
140
+	{
141
+		// needed for restoration
142
+		$this->oldFormat = $this->format;
143
+		$this->format    = $format;
144
+		return $this->format;
145
+	}
146
+
147
+	private function restoreFormat()
148
+	{
149
+		if (!empty($this->oldFormat)) {
150
+			$this->format = $this->oldFormat;
151
+		}
152
+		return $this->format;
153
+	}
154
+
155
+	// expect url, shortened url or hash
156
+	public function getHash($message)
157
+	{
158
+		// if url and not bit.ly get shortened first
159
+		if (strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
160
+			$message = $this->shortenSingle($message);
161
+		}
162
+		$hash = str_replace('http://bit.ly/', '', $message);
163
+		return $hash;
164
+	}
165
+
166
+	public function shortenSingle($message)
167
+	{
168
+		$this->setReturnFormat('json');
169
+		$data = json_decode($this->shorten($message), true);
170
+		// return to previous state.
171
+		$this->restoreFormat();
172
+
173
+		// replace every long url with short one
174
+		foreach ($data['results'] as $url => $d) {
175
+			$message = str_replace($url, $d['shortUrl'], $message);
176
+		}
177
+		return $message;
178
+	}
179
+
180
+	public function expandSingle($shortUrl)
181
+	{
182
+		$this->setReturnFormat('json');
183
+		$data = json_decode($this->expand($shortUrl), true);
184
+		$this->restoreFormat();
185
+		return $data['results'][$this->getHash($shortUrl)]['longUrl'];
186
+	}
187
+
188
+	public function getInfoArray($url)
189
+	{
190
+		$this->setReturnFormat('json');
191
+		$json = $this->info($url);
192
+		$this->restoreFormat();
193
+		$data = json_decode($json, true);
194
+
195
+		$this->infoArray = array_pop($data['results']);
196
+		return $this->infoArray;
197
+	}
198
+
199
+	public function getStatsArray($url)
200
+	{
201
+		$this->setReturnFormat('json');
202
+		$json = $this->stats($url);
203
+		$this->restoreFormat();
204
+		$data             = json_decode($json, true);
205
+		$this->statsArray = $data['results'];
206
+		return $this->statsArray;
207
+	}
208
+
209
+	public function getClicks()
210
+	{
211
+		return $this->statsArray['clicks'];
212
+	}
213
+
214
+	// get thumbnail (small, middle, large)
215
+	public function getThumbnail($size = 'small')
216
+	{
217
+		if (!in_array($size, array('small', 'medium', 'large'))) {
218
+			throw new Exception('Invalid size value');
219
+		}
220
+		if (empty($this->infoArray)) {
221
+			throw new Exception('Info not loaded');
222
+		}
223
+		return $this->infoArray['thumbnail'][$size];
224
+	}
225
+
226
+	public function getTitle()
227
+	{
228
+		return $this->infoArray['htmlTitle'];
229
+	}
230 230
 }
Please login to merge, or discard this patch.
plugins/actions/twitter/twitter.php 1 patch
Indentation   +2487 added lines, -2487 removed lines patch added patch discarded remove patch
@@ -41,2493 +41,2493 @@
 block discarded – undo
41 41
  */
42 42
 class Twitter
43 43
 {
44
-    // internal constant to enable/disable debugging
45
-    const DEBUG = false;
46
-
47
-    // url for the twitter-api
48
-    const API_URL        = 'https://api.twitter.com/1';
49
-    const SECURE_API_URL = 'https://api.twitter.com';
50
-
51
-    // port for the twitter-api
52
-    const API_PORT        = 443;
53
-    const SECURE_API_PORT = 443;
54
-
55
-    // current version
56
-    const VERSION = '2.0.1';
57
-
58
-    /**
59
-     * A cURL instance
60
-     *
61
-     * @var    resource
62
-     */
63
-    private $curl;
64
-
65
-    /**
66
-     * The consumer key
67
-     *
68
-     * @var    string
69
-     */
70
-    private $consumerKey;
71
-
72
-    /**
73
-     * The consumer secret
74
-     *
75
-     * @var    string
76
-     */
77
-    private $consumerSecret;
78
-
79
-    /**
80
-     * The oAuth-token
81
-     *
82
-     * @var    string
83
-     */
84
-    private $oAuthToken = '';
85
-
86
-    /**
87
-     * The oAuth-token-secret
88
-     *
89
-     * @var    string
90
-     */
91
-    private $oAuthTokenSecret = '';
92
-
93
-    /**
94
-     * The timeout
95
-     *
96
-     * @var    int
97
-     */
98
-    private $timeOut = 60;
99
-
100
-    /**
101
-     * The user agent
102
-     *
103
-     * @var    string
104
-     */
105
-    private $userAgent;
106
-
107
-    // class methods
108
-    /**
109
-     * Default constructor
110
-     *
111
-     *
112
-     * @param    string $consumerKey    The consumer key to use.
113
-     * @param    string $consumerSecret The consumer secret to use.
114
-     */
115
-    public function __construct($consumerKey, $consumerSecret)
116
-    {
117
-        $this->setConsumerKey($consumerKey);
118
-        $this->setConsumerSecret($consumerSecret);
119
-    }
120
-
121
-    /**
122
-     * Default destructor
123
-     *
124
-     * @return    void
125
-     */
126
-    public function __destruct()
127
-    {
128
-        if ($this->curl != null) curl_close($this->curl);
129
-    }
130
-
131
-    /**
132
-     * Format the parameters as a querystring
133
-     *
134
-     * @return    string
135
-     * @param    array $parameters
136
-     */
137
-    private function buildQuery(array $parameters)
138
-    {
139
-        // no parameters?
140
-        if (empty($parameters)) return '';
141
-
142
-        // encode the keys
143
-        $keys = self::urlencode_rfc3986(array_keys($parameters));
144
-
145
-        // encode the values
146
-        $values = self::urlencode_rfc3986(array_values($parameters));
147
-
148
-        // reset the parameters
149
-        $parameters = array_combine($keys, $values);
150
-
151
-        // sort parameters by key
152
-        uksort($parameters, 'strcmp');
153
-
154
-        // loop parameters
155
-        foreach ($parameters as $key => $value) {
156
-            // sort by value
157
-            if (is_array($value)) $parameters[$key] = natsort($value);
158
-        }
159
-
160
-        // process parameters
161
-        foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value);
162
-
163
-        // return
164
-        return implode('&', $chunks);
165
-    }
166
-
167
-    /**
168
-     * All OAuth 1.0 requests use the same basic algorithm for creating a signature base string and a signature.
169
-     * The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed,
170
-     * complete with path (but not query parameters), followed by an ampersand ("&").
171
-     * Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored),
172
-     * including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and
173
-     * then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for each parameter are URL encoded in isolation.
174
-     * Instead of using the equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then joined by the
175
-     * URL-escaped ampersand sign, "%26".
176
-     *
177
-     * @return    string
178
-     * @param    string $url
179
-     * @param    string $method
180
-     * @param    array  $parameters
181
-     */
182
-    private function calculateBaseString($url, $method, array $parameters)
183
-    {
184
-        // redefine
185
-        $url        = (string)$url;
186
-        $parameters = (array)$parameters;
187
-
188
-        // init var
189
-        $pairs  = array();
190
-        $chunks = array();
191
-
192
-        // sort parameters by key
193
-        uksort($parameters, 'strcmp');
194
-
195
-        // loop parameters
196
-        foreach ($parameters as $key => $value) {
197
-            // sort by value
198
-            if (is_array($value)) $parameters[$key] = natsort($value);
199
-        }
200
-
201
-        // process queries
202
-        foreach ($parameters as $key => $value) {
203
-            $chunks[] = self::urlencode_rfc3986($key) . '%3D' . self::urlencode_rfc3986($value);
204
-        }
205
-
206
-        // buils base
207
-        $base = $method . '&';
208
-        $base .= urlencode($url) . '&';
209
-        $base .= implode('%26', $chunks);
210
-
211
-        // return
212
-        return $base;
213
-    }
214
-
215
-    /**
216
-     * Build the Authorization header
217
-     * @later: fix me
218
-     *
219
-     *
220
-     * @param    array $parameters
221
-     * @param null     $url
222
-     * @return string
223
-     */
224
-    private function calculateHeader(array $parameters, $url = null)
225
-    {
226
-        // redefine
227
-        $url = (string)$url;
228
-
229
-        // divide into parts
230
-        $parts = parse_url($url);
231
-
232
-        // init var
233
-        $chunks = array();
234
-
235
-        // process queries
236
-        foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
237
-
238
-        // build return
239
-        $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
240
-        $return .= implode(',', $chunks);
241
-
242
-        // prepend name and OAuth part
243
-        return $return;
244
-    }
245
-
246
-    /**
247
-     * Make an call to the oAuth
248
-     * @todo    refactor me
249
-     *
250
-     *
251
-     * @param    string $method
252
-     * @param array     $parameters [optional] $parameters
253
-     * @return array
254
-     * @throws TwitterException
255
-     */
256
-    private function doOAuthCall($method, array $parameters = null)
257
-    {
258
-        // redefine
259
-        $method = (string)$method;
260
-
261
-        // append default parameters
262
-        $parameters['oauth_consumer_key']     = $this->getConsumerKey();
263
-        $parameters['oauth_nonce']            = md5(microtime() . rand());
264
-        $parameters['oauth_timestamp']        = time();
265
-        $parameters['oauth_signature_method'] = 'HMAC-SHA1';
266
-        $parameters['oauth_version']          = '1.0';
267
-
268
-        // calculate the base string
269
-        $base = $this->calculateBaseString(self::SECURE_API_URL . '/oauth/' . $method, 'POST', $parameters);
270
-
271
-        // add sign into the parameters
272
-        $parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
273
-
274
-        // calculate header
275
-        $header = $this->calculateHeader($parameters, self::SECURE_API_URL . '/oauth/' . $method);
276
-
277
-        // set options
278
-        $options[CURLOPT_URL]            = self::SECURE_API_URL . '/oauth/' . $method;
279
-        $options[CURLOPT_PORT]           = self::SECURE_API_PORT;
280
-        $options[CURLOPT_USERAGENT]      = $this->getUserAgent();
281
-        $options[CURLOPT_FOLLOWLOCATION] = true;
282
-        $options[CURLOPT_RETURNTRANSFER] = true;
283
-        $options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
284
-        $options[CURLOPT_SSL_VERIFYPEER] = false;
285
-        $options[CURLOPT_SSL_VERIFYHOST] = false;
286
-        $options[CURLOPT_HTTPHEADER]     = array('Expect:');
287
-        $options[CURLOPT_POST]           = 1;
288
-        $options[CURLOPT_POSTFIELDS]     = $this->buildQuery($parameters);
289
-
290
-        // init
291
-        if ($this->curl == null) $this->curl = curl_init();
292
-
293
-        // set options
294
-        curl_setopt_array($this->curl, $options);
295
-
296
-        // execute
297
-        $response = curl_exec($this->curl);
298
-        $headers  = curl_getinfo($this->curl);
299
-
300
-        // fetch errors
301
-        $errorNumber  = curl_errno($this->curl);
302
-        $errorMessage = curl_error($this->curl);
303
-
304
-        // error?
305
-        if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber);
306
-
307
-        // init var
308
-        $return = array();
309
-
310
-        // parse the string
311
-        parse_str($response, $return);
312
-
313
-        // return
314
-        return $return;
315
-    }
316
-
317
-    /**
318
-     * Make the call
319
-     *
320
-     *
321
-     * @param    string $url
322
-     * @param array     $parameters
323
-     * @param bool      $authenticate
324
-     * @param string    $method
325
-     * @param null      $filePath
326
-     * @param bool      $expectJSON
327
-     * @return string
328
-     * @throws TwitterException
329
-     * @internal param $array [optiona] $aParameters
330
-     * @internal param $bool [optional] $authenticate
331
-     * @internal param $bool [optional] $usePost
332
-     */
333
-    private function doCall($url, array $parameters = null, $authenticate = false, $method = 'GET', $filePath = null, $expectJSON = true)
334
-    {
335
-        // allowed methods
336
-        $allowedMethods = array('GET', 'POST');
337
-
338
-        // redefine
339
-        $url          = (string)$url;
340
-        $parameters   = (array)$parameters;
341
-        $authenticate = (bool)$authenticate;
342
-        $method       = (string)$method;
343
-        $expectJSON   = (bool)$expectJSON;
344
-
345
-        // validate method
346
-        if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
347
-
348
-        // append default parameters
349
-        $oauth['oauth_consumer_key']     = $this->getConsumerKey();
350
-        $oauth['oauth_nonce']            = md5(microtime() . rand());
351
-        $oauth['oauth_timestamp']        = time();
352
-        $oauth['oauth_token']            = $this->getOAuthToken();
353
-        $oauth['oauth_signature_method'] = 'HMAC-SHA1';
354
-        $oauth['oauth_version']          = '1.0';
355
-
356
-        // set data
357
-        $data = $oauth;
358
-        if (!empty($parameters)) $data = array_merge($data, $parameters);
359
-
360
-        // calculate the base string
361
-        $base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data);
362
-
363
-        // add sign into the parameters
364
-        $oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
365
-
366
-        $headers[] = $this->calculateHeader($oauth, self::API_URL . '/' . $url);
367
-        $headers[] = 'Expect:';
368
-
369
-        // based on the method, we should handle the parameters in a different way
370
-        if ($method === 'POST') {
371
-            // file provided?
372
-            if ($filePath != null) {
373
-                // build a boundary
374
-                $boundary = md5(time());
375
-
376
-                // process file
377
-                $fileInfo = pathinfo($filePath);
378
-
379
-                // set mimeType
380
-                $mimeType = 'application/octet-stream';
381
-                if ($fileInfo['extension'] === 'jpg' || $fileInfo['extension'] === 'jpeg') {
382
-                    $mimeType = 'image/jpeg';
383
-                } elseif ($fileInfo['extension'] === 'gif') $mimeType = 'image/gif';
384
-                elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png';
385
-
386
-                // init var
387
-                $content = '--' . $boundary . "\r\n";
388
-
389
-                // set file
390
-                $content = 'Content-Disposition: form-data; name="image";filename="' . $fileInfo['basename'] . '"' . "\r\n" . 'Content-Type: ' . $mimeType . "\r\n\r\n" . file_get_contents($filePath) . "\r\n--" . $boundary . "\r\n";
391
-
392
-                // build headers
393
-                $headers[] = 'Content-Type: multipart/form-data; boundary=' . $boundary;
394
-                $headers[] = 'Content-Length: ' . strlen($content);
395
-
396
-                // set content
397
-                $options[CURLOPT_POSTFIELDS] = $content;
398
-            } // no file
399
-            else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
400
-
401
-            // enable post
402
-            $options[CURLOPT_POST] = 1;
403
-        } else {
404
-            // add the parameters into the querystring
405
-            if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters);
406
-        }
407
-
408
-        // set options
409
-        $options[CURLOPT_URL]            = self::API_URL . '/' . $url;
410
-        $options[CURLOPT_PORT]           = self::API_PORT;
411
-        $options[CURLOPT_USERAGENT]      = $this->getUserAgent();
412
-        $options[CURLOPT_FOLLOWLOCATION] = true;
413
-        $options[CURLOPT_RETURNTRANSFER] = true;
414
-        $options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
415
-        $options[CURLOPT_SSL_VERIFYPEER] = false;
416
-        $options[CURLOPT_SSL_VERIFYHOST] = false;
417
-        $options[CURLOPT_HTTP_VERSION]   = CURL_HTTP_VERSION_1_1;
418
-        $options[CURLOPT_HTTPHEADER]     = $headers;
419
-
420
-        // init
421
-        if ($this->curl == null) $this->curl = curl_init();
422
-
423
-        // set options
424
-        curl_setopt_array($this->curl, $options);
425
-
426
-        // execute
427
-        $response = curl_exec($this->curl);
428
-        $headers  = curl_getinfo($this->curl);
429
-
430
-        // fetch errors
431
-        $errorNumber  = curl_errno($this->curl);
432
-        $errorMessage = curl_error($this->curl);
433
-
434
-        // we don't expext JSON, return the response
435
-        if (!$expectJSON) return $response;
436
-
437
-        // replace ids with their string values, added because of some PHP-version can't handle these large values
438
-        $response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
439
-
440
-        // we expect JSON, so decode it
441
-        $json = @json_decode($response, true);
442
-
443
-        // validate JSON
444
-        if ($json === null) {
445
-            // should we provide debug information
446
-            if (self::DEBUG) {
447
-                // make it output proper
448
-                echo '<pre>';
449
-
450
-                // dump the header-information
451
-                var_dump($headers);
452
-
453
-                // dump the error
454
-                var_dump($errorMessage);
455
-
456
-                // dump the raw response
457
-                var_dump($response);
458
-
459
-                // end proper format
460
-                echo '</pre>';
461
-            }
462
-
463
-            // throw exception
464
-            throw new TwitterException('Invalid response.');
465
-        }
466
-
467
-        // any errors
468
-        if (isset($json['errors'])) {
469
-            // should we provide debug information
470
-            if (self::DEBUG) {
471
-                // make it output proper
472
-                echo '<pre>';
473
-
474
-                // dump the header-information
475
-                var_dump($headers);
476
-
477
-                // dump the error
478
-                var_dump($errorMessage);
479
-
480
-                // dump the raw response
481
-                var_dump($response);
482
-
483
-                // end proper format
484
-                echo '</pre>';
485
-            }
486
-
487
-            // throw exception
488
-            if (isset($json['errors'][0]['message'])) {
489
-                throw new TwitterException($json['errors'][0]['message']);
490
-            } else throw new TwitterException('Invalid response.');
491
-        }
492
-
493
-        // any error
494
-        if (isset($json['error'])) {
495
-            // should we provide debug information
496
-            if (self::DEBUG) {
497
-                // make it output proper
498
-                echo '<pre>';
499
-
500
-                // dump the header-information
501
-                var_dump($headers);
502
-
503
-                // dump the raw response
504
-                var_dump($response);
505
-
506
-                // end proper format
507
-                echo '</pre>';
508
-            }
509
-
510
-            // throw exception
511
-            throw new TwitterException($json['error']);
512
-        }
513
-
514
-        // return
515
-        return $json;
516
-    }
517
-
518
-    /**
519
-     * Get the consumer key
520
-     *
521
-     * @return    string
522
-     */
523
-    private function getConsumerKey()
524
-    {
525
-        return $this->consumerKey;
526
-    }
527
-
528
-    /**
529
-     * Get the consumer secret
530
-     *
531
-     * @return    string
532
-     */
533
-    private function getConsumerSecret()
534
-    {
535
-        return $this->consumerSecret;
536
-    }
537
-
538
-    /**
539
-     * Get the oAuth-token
540
-     *
541
-     * @return    string
542
-     */
543
-    private function getOAuthToken()
544
-    {
545
-        return $this->oAuthToken;
546
-    }
547
-
548
-    /**
549
-     * Get the oAuth-token-secret
550
-     *
551
-     * @return    string
552
-     */
553
-    private function getOAuthTokenSecret()
554
-    {
555
-        return $this->oAuthTokenSecret;
556
-    }
557
-
558
-    /**
559
-     * Get the timeout
560
-     *
561
-     * @return    int
562
-     */
563
-    public function getTimeOut()
564
-    {
565
-        return (int)$this->timeOut;
566
-    }
567
-
568
-    /**
569
-     * Get the useragent that will be used. Our version will be prepended to yours.
570
-     * It will look like: "PHP Twitter/<version> <your-user-agent>"
571
-     *
572
-     * @return    string
573
-     */
574
-    public function getUserAgent()
575
-    {
576
-        return (string)'PHP Twitter/' . self::VERSION . ' ' . $this->userAgent;
577
-    }
578
-
579
-    /**
580
-     * Set the consumer key
581
-     *
582
-     * @return    void
583
-     * @param    string $key The consumer key to use.
584
-     */
585
-    private function setConsumerKey($key)
586
-    {
587
-        $this->consumerKey = (string)$key;
588
-    }
589
-
590
-    /**
591
-     * Set the consumer secret
592
-     *
593
-     * @return    void
594
-     * @param    string $secret The consumer secret to use.
595
-     */
596
-    private function setConsumerSecret($secret)
597
-    {
598
-        $this->consumerSecret = (string)$secret;
599
-    }
600
-
601
-    /**
602
-     * Set the oAuth-token
603
-     *
604
-     * @return    void
605
-     * @param    string $token The token to use.
606
-     */
607
-    public function setOAuthToken($token)
608
-    {
609
-        $this->oAuthToken = (string)$token;
610
-    }
611
-
612
-    /**
613
-     * Set the oAuth-secret
614
-     *
615
-     * @return    void
616
-     * @param    string $secret The secret to use.
617
-     */
618
-    public function setOAuthTokenSecret($secret)
619
-    {
620
-        $this->oAuthTokenSecret = (string)$secret;
621
-    }
622
-
623
-    /**
624
-     * Set the timeout
625
-     *
626
-     * @return    void
627
-     * @param    int $seconds The timeout in seconds
628
-     */
629
-    public function setTimeOut($seconds)
630
-    {
631
-        $this->timeOut = (int)$seconds;
632
-    }
633
-
634
-    /**
635
-     * Get the useragent that will be used. Our version will be prepended to yours.
636
-     * It will look like: "PHP Twitter/<version> <your-user-agent>"
637
-     *
638
-     * @return    void
639
-     * @param    string $userAgent Your user-agent, it should look like <app-name>/<app-version>
640
-     */
641
-    public function setUserAgent($userAgent)
642
-    {
643
-        $this->userAgent = (string)$userAgent;
644
-    }
645
-
646
-    /**
647
-     * Build the signature for the data
648
-     *
649
-     * @return    string
650
-     * @param    string $key  The key to use for signing.
651
-     * @param    string $data The data that has to be signed.
652
-     */
653
-    private function hmacsha1($key, $data)
654
-    {
655
-        return base64_encode(hash_hmac('SHA1', $data, $key, true));
656
-    }
657
-
658
-    /**
659
-     * URL-encode method for internatl use
660
-     *
661
-     * @return    string
662
-     * @param    mixed $value The value to encode.
663
-     */
664
-    private static function urlencode_rfc3986($value)
665
-    {
666
-        if (is_array($value)) {
667
-            return array_map(array('Twitter', 'urlencode_rfc3986'), $value);
668
-        } else {
669
-            $search  = array('+', ' ', '%7E', '%');
670
-            $replace = array('%20', '%20', '~', '%25');
671
-
672
-            return str_replace($search, $replace, urlencode($value));
673
-        }
674
-    }
675
-
676
-
677
-    // Timeline resources
678
-    /**
679
-     * Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
680
-     * The public timeline is cached for 60 seconds and requesting it more often than that is unproductive and a waste of resources.
681
-     *
682
-     * @return    array
683
-     * @param    bool [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
684
-     */
685
-    public function statusesPublicTimeline($skipUser = false)
686
-    {
687
-        // redefine
688
-        $skipUser = (bool)$skipUser;
689
-
690
-        // build parameters
691
-        $parameters = array();
692
-        if ($skipUser) $parameters['skip_user'] = 'true';
693
-
694
-        // make the call
695
-        return (array)$this->doCall('statuses/public_timeline.json', $parameters);
696
-    }
697
-
698
-    /**
699
-     * Returns the 20 most recent statuses posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web.
700
-     *
701
-     * @return    array
702
-     * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
703
-     * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
704
-     * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
705
-     * @param    int    [optional] $page            Specifies the page of results to retrieve.
706
-     * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
707
-     */
708
-    public function statusesHomeTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
709
-    {
710
-        // redefine
711
-        $skipUser = (bool)$skipUser;
712
-
713
-        // build parameters
714
-        $parameters = array();
715
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
716
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
717
-        if ($count != null) $parameters['count'] = (int)$count;
718
-        if ($page != null) $parameters['page'] = (int)$page;
719
-        if ($skipUser) $parameters['skip_user'] = 'true';
720
-
721
-        // make the call
722
-        return (array)$this->doCall('statuses/home_timeline.json', $parameters, true);
723
-    }
724
-
725
-    /**
726
-     * Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends.
727
-     * This is the equivalent of /timeline/home on the Web.
728
-     *
729
-     * Usage note: This home_timeline call is identical to statuses/friends_timeline, except that home_timeline also contains retweets, while statuses/friends_timeline does not for backwards compatibility reasons.
730
-     * In a future version of the API, statuses/friends_timeline will be deprected and replaced by home_timeline.
731
-     *
732
-     * @return    array
733
-     * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
734
-     * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
735
-     * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
736
-     * @param    int    [optional] $page            Specifies the page of results to retrieve.
737
-     * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
738
-     */
739
-    public function statusesFriendsTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
740
-    {
741
-        // redefine
742
-        $skipUser = (bool)$skipUser;
743
-
744
-        // build parameters
745
-        $parameters = array();
746
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
747
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
748
-        if ($count != null) $parameters['count'] = (int)$count;
749
-        if ($page != null) $parameters['page'] = (int)$page;
750
-        if ($skipUser) $parameters['skip_user'] = 'true';
751
-
752
-        // make the call
753
-        return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true);
754
-    }
755
-
756
-    /**
757
-     * Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
758
-     * This is the equivalent of the Web / page for your own user, or the profile page for a third party.
759
-     *
760
-     * For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom).
761
-     * If you'd like them included, you can merge them in from statuses retweeted_by_me.
762
-     *
763
-     * @return    array
764
-     * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
765
-     * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
766
-     * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
767
-     * @param    string [optional] $sinceId        Returns results with an ID greater than (that is, more recent than) the specified ID.
768
-     * @param    string [optional] $maxId            Returns results with an ID less than (that is, older than) or equal to the specified ID.
769
-     * @param    int    [optional] $count            Specifies the number of records to retrieve. May not be greater than 200.
770
-     * @param    int    [optional] $page                Specifies the page of results to retrieve.
771
-     * @param    bool   [optional] $skipUser        When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
772
-     */
773
-    public function statusesUserTimeline($id = null, $userId = null, $screenName = null, $sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
774
-    {
775
-        // redefine
776
-        $skipUser = (bool)$skipUser;
777
-
778
-        // build parameters
779
-        $parameters = array();
780
-        if ($id != null) $parameters['id'] = (string)$id;
781
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
782
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
783
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
784
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
785
-        if ($count != null) $parameters['count'] = (int)$count;
786
-        if ($page != null) $parameters['page'] = (int)$page;
787
-        if ($skipUser) $parameters['skip_user'] = 'true';
788
-
789
-        // make the call
790
-        return (array)$this->doCall('statuses/user_timeline.json', $parameters, true);
791
-    }
792
-
793
-    /**
794
-     * Returns the 20 most recent mentions (status containing @username) for the authenticating user.
795
-     *
796
-     *
797
-     * @param null $sinceId
798
-     * @param null $maxId
799
-     * @param null $count
800
-     * @param null $page
801
-     * @return array
802
-     * @throws TwitterException
803
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
804
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
805
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
806
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
807
-     */
808
-    public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null)
809
-    {
810
-        // validate
811
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
812
-
813
-        // build parameters
814
-        $parameters = array();
815
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
816
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
817
-        if ($count != null) $parameters['count'] = (int)$count;
818
-        if ($page != null) $parameters['page'] = (int)$page;
819
-
820
-        // make the call
821
-        return (array)$this->doCall('statuses/mentions.json', $parameters);
822
-    }
823
-
824
-    /**
825
-     * Returns the 20 most recent retweets posted by the authenticating user.
826
-     *
827
-     *
828
-     * @param null $sinceId
829
-     * @param null $maxId
830
-     * @param null $count
831
-     * @param null $page
832
-     * @return array
833
-     * @throws TwitterException
834
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
835
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
836
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
837
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
838
-     */
839
-    public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null)
840
-    {
841
-        // validate
842
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
843
-
844
-        // build parameters
845
-        $parameters = array();
846
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
847
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
848
-        if ($count != null) $parameters['count'] = (int)$count;
849
-        if ($page != null) $parameters['page'] = (int)$page;
850
-
851
-        // make the call
852
-        return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
853
-    }
854
-
855
-    /**
856
-     * Returns the 20 most recent retweets posted by the authenticating user's friends.
857
-     *
858
-     *
859
-     * @param null $sinceId
860
-     * @param null $maxId
861
-     * @param null $count
862
-     * @param null $page
863
-     * @return array
864
-     * @throws TwitterException
865
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
866
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
867
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
868
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
869
-     */
870
-    public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null)
871
-    {
872
-        // validate
873
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
874
-
875
-        // build parameters
876
-        $parameters = array();
877
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
878
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
879
-        if ($count != null) $parameters['count'] = (int)$count;
880
-        if ($page != null) $parameters['page'] = (int)$page;
881
-
882
-        // make the call
883
-        return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
884
-    }
885
-
886
-
887
-    // Tweets resources
888
-    /**
889
-     * Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
890
-     *
891
-     *
892
-     * @param null $sinceId
893
-     * @param null $maxId
894
-     * @param null $count
895
-     * @param null $page
896
-     * @return array
897
-     * @throws TwitterException
898
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
899
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
900
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
901
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
902
-     */
903
-    public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null)
904
-    {
905
-        // validate
906
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
907
-
908
-        // build parameters
909
-        $parameters = array();
910
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
911
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
912
-        if ($count != null) $parameters['count'] = (int)$count;
913
-        if ($page != null) $parameters['page'] = (int)$page;
914
-
915
-        // make the call
916
-        return (array)$this->doCall('statuses/retweets_of_me.json', $parameters);
917
-    }
918
-
919
-    /**
920
-     * Returns a single status, specified by the id parameter below. The status's author will be returned inline.
921
-     *
922
-     * @return    array
923
-     * @param    string $id The numerical ID of the desired status.
924
-     */
925
-    public function statusesShow($id)
926
-    {
927
-        // build parameters
928
-        $parameters['id'] = (string)$id;
929
-
930
-        // make the call
931
-        return (array)$this->doCall('statuses/show.json', $parameters);
932
-    }
933
-
934
-    /**
935
-     * Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
936
-     *
937
-     * @return    array
938
-     * @param    string $status The text of your status update, up to 140 characters. URL encode as necessary.
939
-     * @param           string  [optional] $inReplyToStatusId        The ID of an existing status that the update is in reply to.
940
-     * @param           float   [optional] $lat                    The location's latitude that this tweet refers to.
941
-     * @param           float   [optional] $long                    The location's longitude that this tweet refers to.
942
-     * @param           string  [optional] $placeId                A place in the world. These IDs can be retrieved from geo/reverse_geocode.
943
-     * @param           bool    [optional] $displayCoordinates        Whether or not to put a pin on the exact coordinates a tweet has been sent from.
944
-     */
945
-    public function statusesUpdate($status, $inReplyToStatusId = null, $lat = null, $long = null, $placeId = null, $displayCoordinates = false)
946
-    {
947
-        // build parameters
948
-        $parameters['status'] = (string)$status;
949
-        if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
950
-        if ($lat != null) $parameters['lat'] = (float)$lat;
951
-        if ($long != null) $parameters['long'] = (float)$long;
952
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
953
-        if ($displayCoordinates) $parameters['display_coordinates'] = 'true';
954
-
955
-        // make the call
956
-        return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST');
957
-    }
958
-
959
-    /**
960
-     * Destroys the status specified by the required ID parameter.
961
-     * Usage note: The authenticating user must be the author of the specified status.
962
-     *
963
-     * @return    bool
964
-     * @param    string $id The numerical ID of the desired status.
965
-     */
966
-    public function statusesDestroy($id)
967
-    {
968
-        // build parameters
969
-        $parameters['id'] = (string)$id;
970
-
971
-        // make the call
972
-        return (array)$this->doCall('statuses/destroy.json', $parameters, true, 'POST');
973
-    }
974
-
975
-    /**
976
-     * Retweets a tweet. Returns the original tweet with retweet details embedded.
977
-     *
978
-     * @return    array
979
-     * @param    string $id The numerical ID of the desired status.
980
-     */
981
-    public function statusesRetweet($id)
982
-    {
983
-        // make the call
984
-        return (array)$this->doCall('statuses/retweet/' . $id . '.json', null, true, 'POST');
985
-    }
986
-
987
-    /**
988
-     * Returns up to 100 of the first retweets of a given tweet.
989
-     *
990
-     *
991
-     * @param    string $id The numerical ID of the desired status.
992
-     * @param           int [optional] $count    Specifies the number of records to retrieve. May not be greater than 100.
993
-     * @return array
994
-     * @throws TwitterException
995
-     */
996
-    public function statusesRetweets($id, $count = null)
997
-    {
998
-        // validate
999
-        if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.');
1000
-
1001
-        // build parameters
1002
-        $parameters = null;
1003
-        if ($count != null) $parameters['count'] = (int)$count;
1004
-
1005
-        // make the call
1006
-        return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters);
1007
-    }
1008
-
1009
-    /**
1010
-     * Show user objects of up to 100 members who retweeted the status.
1011
-     *
1012
-     *
1013
-     * @param    string $id The numerical ID of the desired status.
1014
-     * @param null      $count
1015
-     * @param null      $page
1016
-     * @return array
1017
-     * @throws TwitterException
1018
-     * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1019
-     * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1020
-     */
1021
-    public function statusesIdRetweetedBy($id, $count = null, $page = null)
1022
-    {
1023
-        // validate
1024
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1025
-
1026
-        // build parameters
1027
-        $parameters = null;
1028
-        if ($count != null) $parameters['count'] = (int)$count;
1029
-        if ($page != null) $parameters['page'] = (int)$page;
1030
-
1031
-        // make the call
1032
-        return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true);
1033
-    }
1034
-
1035
-    /**
1036
-     * Show user ids of up to 100 users who retweeted the status.
1037
-     *
1038
-     *
1039
-     * @param    string $id The numerical ID of the desired status.
1040
-     * @param null      $count
1041
-     * @param null      $page
1042
-     * @return array
1043
-     * @throws TwitterException
1044
-     * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1045
-     * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1046
-     */
1047
-    public function statusesIdRetweetedByIds($id, $count = null, $page = null)
1048
-    {
1049
-        // validate
1050
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1051
-
1052
-        // build parameters
1053
-        $parameters = null;
1054
-        if ($count != null) $parameters['count'] = (int)$count;
1055
-        if ($page != null) $parameters['page'] = (int)$page;
1056
-
1057
-        // make the call
1058
-        return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true);
1059
-    }
1060
-
1061
-
1062
-    // User resources
1063
-    /**
1064
-     * Returns extended information of a given user, specified by ID or screen name as per the required id parameter.
1065
-     * The author's most recent status will be returned inline.
1066
-     *
1067
-     *
1068
-     * @param null $id
1069
-     * @param null $userId
1070
-     * @param null $screenName
1071
-     * @return array
1072
-     * @throws TwitterException
1073
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1074
-     * @internal param $string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1075
-     * @internal param $string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1076
-     */
1077
-    public function usersShow($id = null, $userId = null, $screenName = null)
1078
-    {
1079
-        // validate
1080
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1081
-
1082
-        // build parameters
1083
-        if ($id != null) $parameters['id'] = (string)$id;
1084
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1085
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1086
-
1087
-        // make the call
1088
-        return (array)$this->doCall('users/show.json', $parameters);
1089
-    }
1090
-
1091
-    /**
1092
-     * Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.
1093
-     * The author's most recent status (if the authenticating user has permission) will be returned inline.
1094
-     *
1095
-     *
1096
-     * @param null $userIds
1097
-     * @param null $screenNames
1098
-     * @return array
1099
-     * @throws TwitterException
1100
-     * @internal param $mixed [optional] $userIds        A comma separated list of user IDs, up to 100 in total.
1101
-     * @internal param $mixed [optional] $screenNames    A comma separated list of screen names, up to 100 in total.
1102
-     */
1103
-    public function usersLookup($userIds = null, $screenNames = null)
1104
-    {
1105
-        // redefine
1106
-        $userIds     = (array)$userIds;
1107
-        $screenNames = (array)$screenNames;
1108
-
1109
-        // validate
1110
-        if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
1111
-
1112
-        // build parameters
1113
-        if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds);
1114
-        if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1115
-
1116
-        // make the call
1117
-        return (array)$this->doCall('users/lookup.json', $parameters, true);
1118
-
1119
-    }
1120
-
1121
-    /**
1122
-     * Run a search for users similar to the Find People button on Twitter.com; the same results returned by people search on Twitter.com will be returned by using this API.
1123
-     * Usage note: It is only possible to retrieve the first 1000 matches from this API.
1124
-     *
1125
-     * @return    array
1126
-     * @param    string $q  The search query term.
1127
-     * @param           int [optional] $perPage    Specifies the number of results to retrieve.
1128
-     * @param           int [optional] $page        Specifies the page of results to retrieve.
1129
-     */
1130
-    public function usersSearch($q, $perPage = null, $page = null)
1131
-    {
1132
-        // build parameters
1133
-        $parameters['q'] = (string)$q;
1134
-        if ($perPage != null) $parameters['per_page'] = (int)$perPage;
1135
-        if ($page != null) $parameters['page'] = (int)$page;
1136
-
1137
-        // make the call
1138
-        return (array)$this->doCall('users/search.json', $parameters, true);
1139
-
1140
-    }
1141
-
1142
-    /**
1143
-     * Access to Twitter's suggested user list. This returns the list of suggested user categories. The category can be used in the users/suggestions/category  endpoint to get the users in that category.
1144
-     *
1145
-     * @return    array
1146
-     */
1147
-    public function usersSuggestions()
1148
-    {
1149
-        return (array)$this->doCall('users/suggestions.json', null, true);
1150
-    }
1151
-
1152
-    /**
1153
-     * Access the users in a given category of the Twitter suggested user list.
1154
-     * It is recommended that end clients cache this data for no more than one hour.
1155
-     *
1156
-     * @return    array
1157
-     * @param    string $slug The short name of list or a category.
1158
-     */
1159
-    public function usersSuggestionsSlug($slug)
1160
-    {
1161
-        return (array)$this->doCall('users/suggestions/' . (string)$slug . '.json');
1162
-    }
1163
-
1164
-    /**
1165
-     * Returns a user's friends, each with current status inline. They are ordered by the order in which the user followed them, most recently followed first, 100 at a time.
1166
-     * (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1167
-     *
1168
-     * Use the cursor option to access older friends.
1169
-     * With no user specified, request defaults to the authenticated user's friends.
1170
-     * It's also possible to request another user's friends list via the id, screen_name or user_id parameter.
1171
-     *
1172
-     * @return    array
1173
-     * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1174
-     * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1175
-     * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1176
-     * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1177
-     */
1178
-    public function statusesFriends($id = null, $userId = null, $screenName = null, $cursor = null)
1179
-    {
1180
-        // build parameters
1181
-        $parameters = array();
1182
-        if ($id != null) $parameters['id'] = (string)$id;
1183
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1184
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1185
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1186
-
1187
-        // make the call
1188
-        return (array)$this->doCall('statuses/friends.json', $parameters);
1189
-    }
1190
-
1191
-    /**
1192
-     * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they followed the user, 100 at a time. (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1193
-     * Use the cursor parameter to access earlier followers.
1194
-     *
1195
-     * @return    array
1196
-     * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1197
-     * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1198
-     * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1199
-     * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1200
-     */
1201
-    public function statusesFollowers($id = null, $userId = null, $screenName = null, $cursor = null)
1202
-    {
1203
-        // build parameters
1204
-        $parameters = array();
1205
-        if ($id != null) $parameters['id'] = (string)$id;
1206
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1207
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1208
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1209
-
1210
-        // make the call
1211
-        return (array)$this->doCall('statuses/followers.json', $parameters);
1212
-    }
1213
-
1214
-
1215
-    // Trends resources
1216
-    /**
1217
-     * Returns the top ten topics that are currently trending on Twitter.
1218
-     * The response includes the time of the request, the name of each trend, and the url to the Twitter Search results page for that topic.
1219
-     *
1220
-     * @return    array
1221
-     */
1222
-    public function trends()
1223
-    {
1224
-        return (array)$this->doCall('trends.json');
1225
-    }
1226
-
1227
-    /**
1228
-     * Returns the current top 10 trending topics on Twitter.
1229
-     * The response includes the time of the request, the name of each trending topic, and query used on Twitter Search results page for that topic.
1230
-     *
1231
-     * @return    array
1232
-     * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1233
-     */
1234
-    public function trendsCurrent($exclude = null)
1235
-    {
1236
-        // build parameters
1237
-        $parameters = array();
1238
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1239
-
1240
-        // make the call
1241
-        return (array)$this->doCall('trends/current.json', $parameters);
1242
-    }
1243
-
1244
-    /**
1245
-     * Returns the top 20 trending topics for each hour in a given day.
1246
-     *
1247
-     * @return    array
1248
-     * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1249
-     * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1250
-     */
1251
-    public function trendsDaily($exclude = null, $date = null)
1252
-    {
1253
-        // build parameters
1254
-        $parameters = array();
1255
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1256
-        if ($date != null) $parameters['date'] = (string)$date;
1257
-
1258
-        // make the call
1259
-        return (array)$this->doCall('trends/daily.json', $parameters);
1260
-    }
1261
-
1262
-    /**
1263
-     * Returns the top 30 trending topics for each day in a given week.
1264
-     *
1265
-     * @return    array
1266
-     * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1267
-     * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1268
-     */
1269
-    public function trendsWeekly($exclude = null, $date = null)
1270
-    {
1271
-        // build parameters
1272
-        $parameters = array();
1273
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1274
-        if ($date != null) $parameters['date'] = (string)$date;
1275
-
1276
-        // make the call
1277
-        return (array)$this->doCall('trends/weekly.json', $parameters);
1278
-    }
1279
-
1280
-
1281
-    // List resources
1282
-    /**
1283
-     * Creates a new list for the authenticated user. Accounts are limited to 20 lists.
1284
-     *
1285
-     *
1286
-     * @param    string $user The user.
1287
-     * @param    string $name The name of the list you are creating.
1288
-     * @param null      $mode
1289
-     * @param null      $description
1290
-     * @return array
1291
-     * @throws TwitterException
1292
-     * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1293
-     * @internal param $string [optional] $description    The description of the list you are creating.
1294
-     */
1295
-    public function userListsCreate($user, $name, $mode = null, $description = null)
1296
-    {
1297
-        // possible modes
1298
-        $allowedModes = array('public', 'private');
1299
-
1300
-        // validate
1301
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1302
-
1303
-        // build parameters
1304
-        $parameters['name'] = (string)$name;
1305
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1306
-        if ($description != null) $parameters['description'] = (string)$description;
1307
-
1308
-        // make the call
1309
-        return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST');
1310
-    }
1311
-
1312
-    /**
1313
-     * List the lists of the specified user. Private lists will be included if the authenticated users is the same as the user who's lists are being returned.
1314
-     *
1315
-     * @return    array
1316
-     * @param    string $user  The user.
1317
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1318
-     */
1319
-    public function userLists($user, $cursor = null)
1320
-    {
1321
-        $parameters = null;
1322
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1323
-
1324
-        // make the call
1325
-        return (array)$this->doCall((string)$user . '/lists.json', $parameters, true);
1326
-    }
1327
-
1328
-    /**
1329
-     * Show the specified list. Private lists will only be shown if the authenticated user owns the specified list.
1330
-     *
1331
-     * @return    array
1332
-     * @param    string $user The user.
1333
-     * @param    string $id   The id of the list.
1334
-     */
1335
-    public function userListsId($user, $id)
1336
-    {
1337
-        // make the call
1338
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', null, true);
1339
-    }
1340
-
1341
-    /**
1342
-     * Updates the specified list.
1343
-     *
1344
-     *
1345
-     * @param    string $user The user.
1346
-     * @param    string $id   The id of the list.
1347
-     * @param null      $name
1348
-     * @param null      $mode
1349
-     * @param null      $description
1350
-     * @return array
1351
-     * @throws TwitterException
1352
-     * @internal param $string [optional] $name            The name of the list you are creating.
1353
-     * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1354
-     * @internal param $string [optional] $description    The description of the list you are creating.
1355
-     */
1356
-    public function userListsIdUpdate($user, $id, $name = null, $mode = null, $description = null)
1357
-    {
1358
-        // possible modes
1359
-        $allowedModes = array('public', 'private');
1360
-
1361
-        // validate
1362
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1363
-
1364
-        // build parameters
1365
-        if ($name != null) $parameters['name'] = (string)$name;
1366
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1367
-        if ($description != null) $parameters['description'] = (string)$description;
1368
-
1369
-        // make the call
1370
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST');
1371
-    }
1372
-
1373
-    /**
1374
-     * Show tweet timeline for members of the specified list.
1375
-     *
1376
-     *
1377
-     * @param    string $user The user.
1378
-     * @param    string $id   The id of the list.
1379
-     * @param null      $sinceId
1380
-     * @param null      $maxId
1381
-     * @param null      $count
1382
-     * @param null      $page
1383
-     * @return array
1384
-     * @throws TwitterException
1385
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1386
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1387
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1388
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1389
-     */
1390
-    public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null)
1391
-    {
1392
-        // validate
1393
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1394
-
1395
-        // build parameters
1396
-        $parameters = array();
1397
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1398
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1399
-        if ($count != null) $parameters['per_page'] = (int)$count;
1400
-        if ($page != null) $parameters['page'] = (int)$page;
1401
-
1402
-        // make the call
1403
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters);
1404
-    }
1405
-
1406
-    /**
1407
-     * List the lists the specified user has been added to.
1408
-     *
1409
-     * @return    array
1410
-     * @param    string $user  The user.
1411
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1412
-     */
1413
-    public function userListsMemberships($user, $cursor = null)
1414
-    {
1415
-        $parameters = null;
1416
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1417
-
1418
-        // make the call
1419
-        return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true);
1420
-    }
1421
-
1422
-    /**
1423
-     * List the lists the specified user follows.
1424
-     *
1425
-     * @return    array
1426
-     * @param    string $user  The user.
1427
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1428
-     */
1429
-    public function userListsSubscriptions($user, $cursor = null)
1430
-    {
1431
-        $parameters = null;
1432
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1433
-
1434
-        // make the call
1435
-        return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true);
1436
-    }
1437
-
1438
-
1439
-    // List Members resources
1440
-    /**
1441
-     * Returns the members of the specified list.
1442
-     *
1443
-     * @return    array
1444
-     * @param    string $user  The user.
1445
-     * @param    string $id    The id of the list.
1446
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1447
-     */
1448
-    public function userListMembers($user, $id, $cursor = null)
1449
-    {
1450
-        $parameters = null;
1451
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1452
-
1453
-        // make the call
1454
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true);
1455
-    }
1456
-
1457
-    /**
1458
-     * Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to having 500 members.
1459
-     *
1460
-     * @return    array
1461
-     * @param    string $user   The user.
1462
-     * @param    string $id     The id of the list.
1463
-     * @param    string $userId The id or screen name of the user to add as a member of the list.
1464
-     */
1465
-    public function userListMembersCreate($user, $id, $userId)
1466
-    {
1467
-        // build parameters
1468
-        $parameters['id'] = (string)$userId;
1469
-
1470
-        // make the call
1471
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1472
-    }
1473
-
1474
-    /**
1475
-     * Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list.
1476
-     *
1477
-     * @return    mixed
1478
-     * @param    string $user   The user.
1479
-     * @param    string $id     The id of the list.
1480
-     * @param    string $userId Specfies the ID of the user for whom to return results for.
1481
-     */
1482
-    public function userListMembersDelete($user, $id, $userId)
1483
-    {
1484
-        // build parameters
1485
-        $parameters['id']      = (string)$userId;
1486
-        $parameters['_method'] = 'DELETE';
1487
-
1488
-        // make the call
1489
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1490
-    }
1491
-
1492
-    /**
1493
-     * Check if a user is a member of the specified list.
1494
-     *
1495
-     *
1496
-     * @param    string $user   The user.
1497
-     * @param    string $id     The id of the list.
1498
-     * @param    string $userId Specfies the ID of the user for whom to return results for.
1499
-     * @return mixed
1500
-     * @throws TwitterException
1501
-     */
1502
-    public function userListMembersId($user, $id, $userId)
1503
-    {
1504
-        try {
1505
-            // make the call
1506
-            return (array)$this->doCall((string)$user . '/' . (string)$id . '/members/' . (string)$userId . '.json', null, true);
1507
-        } // catch exceptions
1508
-        catch (TwitterException $e) {
1509
-            if ($e->getMessage() === 'The specified user is not a member of this list') {
1510
-                return false;
1511
-            } else throw $e;
1512
-        }
1513
-    }
1514
-
1515
-
1516
-    // List Subscribers resources
1517
-    /**
1518
-     * Returns the subscribers of the specified list.
1519
-     *
1520
-     * @return    array
1521
-     * @param    string $user  The user.
1522
-     * @param    string $id    The id of the list.
1523
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1524
-     */
1525
-    public function userListSubscribers($user, $id, $cursor = null)
1526
-    {
1527
-        $parameters = null;
1528
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1529
-
1530
-        // make the call
1531
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true);
1532
-    }
1533
-
1534
-    /**
1535
-     * Make the authenticated user follow the specified list.
1536
-     *
1537
-     * @return    array
1538
-     * @param    string $user The user.
1539
-     * @param    string $id   The id of the list.
1540
-     */
1541
-    public function userListSubscribersCreate($user, $id)
1542
-    {
1543
-        // make the call
1544
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', null, true, 'POST');
1545
-    }
1546
-
1547
-    /**
1548
-     * Unsubscribes the authenticated user form the specified list.
1549
-     *
1550
-     * @return    array
1551
-     * @param    string $user The user.
1552
-     * @param    string $id   The id of the list.
1553
-     */
1554
-    public function userListSubscribersDelete($user, $id)
1555
-    {
1556
-        // build parameters
1557
-        $parameters['_method'] = 'DELETE';
1558
-
1559
-        // make the call
1560
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true, 'POST');
1561
-    }
1562
-
1563
-    /**
1564
-     * Check if the specified user is a subscriber of the specified list.
1565
-     *
1566
-     *
1567
-     * @param    string $user   The user.
1568
-     * @param    string $id     The id of the list.
1569
-     * @param    string $userId Specfies the ID of the user for whom to return results for.
1570
-     * @return mixed
1571
-     * @throws TwitterException
1572
-     */
1573
-    public function userListSubscribersId($user, $id, $userId)
1574
-    {
1575
-        try {
1576
-            // make the call
1577
-            return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers/' . (string)$userId . '.json', null, true);
1578
-        } // catch exceptions
1579
-        catch (TwitterException $e) {
1580
-            if ($e->getMessage() === 'The specified user is not a subscriber of this list') {
1581
-                return false;
1582
-            } else throw $e;
1583
-        }
1584
-
1585
-    }
1586
-
1587
-
1588
-    // Direct Messages resources
1589
-    /**
1590
-     * Returns a list of the 20 most recent direct messages sent to the authenticating user.
1591
-     *
1592
-     *
1593
-     * @param null $sinceId
1594
-     * @param null $maxId
1595
-     * @param null $count
1596
-     * @param null $page
1597
-     * @return array
1598
-     * @throws TwitterException
1599
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1600
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1601
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1602
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1603
-     */
1604
-    public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null)
1605
-    {
1606
-        // validate
1607
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1608
-
1609
-        // build parameters
1610
-        $parameters = array();
1611
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1612
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1613
-        if ($count != null) $parameters['count'] = (int)$count;
1614
-        if ($page != null) $parameters['page'] = (int)$page;
1615
-
1616
-        // make the call
1617
-        return (array)$this->doCall('direct_messages.json', $parameters, true);
1618
-    }
1619
-
1620
-    /**
1621
-     * Returns a list of the 20 most recent direct messages sent by the authenticating user.
1622
-     *
1623
-     *
1624
-     * @param null $sinceId
1625
-     * @param null $maxId
1626
-     * @param null $count
1627
-     * @param null $page
1628
-     * @return array
1629
-     * @throws TwitterException
1630
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1631
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1632
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1633
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1634
-     */
1635
-    public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null)
1636
-    {
1637
-        // validate
1638
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1639
-
1640
-        // build parameters
1641
-        $parameters = array();
1642
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1643
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1644
-        if ($count != null) $parameters['count'] = (int)$count;
1645
-        if ($page != null) $parameters['page'] = (int)$page;
1646
-
1647
-        // make the call
1648
-        return (array)$this->doCall('direct_messages/sent.json', $parameters, true);
1649
-    }
1650
-
1651
-    /**
1652
-     * Sends a new direct message to the specified user from the authenticating user.
1653
-     * Requires both the user and text parameters. Returns the sent message in the requested format when successful.
1654
-     *
1655
-     *
1656
-     * @param    string $text The text of your direct message. Be sure to URL encode as necessary, and keep it under 140 characters.
1657
-     * @param null      $id
1658
-     * @param null      $userId
1659
-     * @param null      $screenName
1660
-     * @return array
1661
-     * @throws TwitterException
1662
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1663
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1664
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1665
-     */
1666
-    public function directMessagesNew($text, $id = null, $userId = null, $screenName = null)
1667
-    {
1668
-        // validate
1669
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1670
-
1671
-        // build parameters
1672
-        $parameters['text'] = (string)$text;
1673
-        if ($id != null) $parameters['user'] = (string)$id;
1674
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1675
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1676
-
1677
-        // make the call
1678
-        return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST');
1679
-    }
1680
-
1681
-    /**
1682
-     * Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message.
1683
-     *
1684
-     * @return    array
1685
-     * @param    string $id The ID of the desired direct message.
1686
-     */
1687
-    public function directMessagesDestroy($id)
1688
-    {
1689
-        // build parameters
1690
-        $parameters['id'] = (string)$id;
1691
-
1692
-        // make the call
1693
-        return (array)$this->doCall('direct_messages/destroy.json', $parameters, true, 'POST');
1694
-    }
1695
-
1696
-
1697
-    // Friendship resources
1698
-    /**
1699
-     * Allows the authenticating users to follow the user specified in the ID parameter.
1700
-     * Returns the befriended user in the requested format when successful.
1701
-     * Returns a string describing the failure condition when unsuccessful.
1702
-     *
1703
-     *
1704
-     * @param null $id
1705
-     * @param null $userId
1706
-     * @param null $screenName
1707
-     * @param bool $follow
1708
-     * @return mixed
1709
-     * @throws TwitterException
1710
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1711
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1712
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1713
-     * @internal param $bool [optional] $follow            Returns public statuses that reference the given set of users.
1714
-     */
1715
-    public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false)
1716
-    {
1717
-        // validate
1718
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1719
-
1720
-        // build parameters
1721
-        if ($id != null) $parameters['id'] = (string)$id;
1722
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1723
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1724
-        $parameters['follow'] = $follow ? 'true' : 'false';
1725
-
1726
-        // make the call
1727
-        return (array)$this->doCall('friendships/create.json', $parameters, true, 'POST');
1728
-    }
1729
-
1730
-    /**
1731
-     * Allows the authenticating users to unfollow the user specified in the ID parameter.
1732
-     * Returns the unfollowed user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
1733
-     *
1734
-     *
1735
-     * @param null $id
1736
-     * @param null $userId
1737
-     * @param null $screenName
1738
-     * @return array
1739
-     * @throws TwitterException
1740
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1741
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1742
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1743
-     */
1744
-    public function friendshipsDestroy($id = null, $userId = null, $screenName = null)
1745
-    {
1746
-        // validate
1747
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1748
-
1749
-        // build parameters
1750
-        if ($id != null) $parameters['id'] = (string)$id;
1751
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1752
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1753
-
1754
-        // make the call
1755
-        return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST');
1756
-    }
1757
-
1758
-    /**
1759
-     * Tests for the existence of friendship between two users. Will return true if user_a follows user_b, otherwise will return false.
1760
-     *
1761
-     * @return    bool
1762
-     * @param    string $userA The ID or screen_name of the subject user.
1763
-     * @param    string $userB The ID or screen_name of the user to test for following.
1764
-     */
1765
-    public function friendshipsExists($userA, $userB)
1766
-    {
1767
-        // build parameters
1768
-        $parameters['user_a'] = (string)$userA;
1769
-        $parameters['user_b'] = (string)$userB;
1770
-
1771
-        // make the call
1772
-        return (bool)$this->doCall('friendships/exists.json', $parameters);
1773
-    }
1774
-
1775
-    /**
1776
-     * Returns detailed information about the relationship between two users.
1777
-     *
1778
-     *
1779
-     * @param null $sourceId
1780
-     * @param null $sourceScreenName
1781
-     * @param null $targetId
1782
-     * @param null $targetScreenName
1783
-     * @return array
1784
-     * @throws TwitterException
1785
-     * @internal param $string [optional] $sourceId                The user_id of the subject user.
1786
-     * @internal param $string [optional] $sourceScreenName        The screen_name of the subject user.
1787
-     * @internal param $string [optional] $targetId                The screen_name of the subject user.
1788
-     * @internal param $string [optional] $targetScreenName        The screen_name of the target user.
1789
-     */
1790
-    public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
1791
-    {
1792
-        // validate
1793
-        if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.');
1794
-        if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
1795
-
1796
-        // build parameters
1797
-        if ($sourceId != null) $parameters['source_id'] = (string)$sourceId;
1798
-        if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName;
1799
-        if ($targetId != null) $parameters['target_id'] = (string)$targetId;
1800
-        if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName;
1801
-
1802
-        // make the call
1803
-        return (array)$this->doCall('friendships/show.json', $parameters);
1804
-    }
1805
-
1806
-    /**
1807
-     * Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user.
1808
-     *
1809
-     * @return    array
1810
-     * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1811
-     */
1812
-    public function friendshipsIncoming($cursor = null)
1813
-    {
1814
-        $parameters = null;
1815
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1816
-
1817
-        // make the call
1818
-        return (array)$this->doCall('friendships/incoming.json', $parameters, true);
1819
-    }
1820
-
1821
-    /**
1822
-     * Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request.
1823
-     *
1824
-     * @return    array
1825
-     * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1826
-     */
1827
-    public function friendshipsOutgoing($cursor = null)
1828
-    {
1829
-        $parameters = null;
1830
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1831
-
1832
-        // make the call
1833
-        return (array)$this->doCall('friendships/outgoing.json', $parameters, true);
1834
-    }
1835
-
1836
-
1837
-    // Friends and Followers resources
1838
-    /**
1839
-     * Returns an array of numeric IDs for every user the specified user is following.
1840
-     *
1841
-     *
1842
-     * @param null $id
1843
-     * @param null $userId
1844
-     * @param null $screenName
1845
-     * @param null $cursor
1846
-     * @return array
1847
-     * @throws TwitterException
1848
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1849
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1850
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1851
-     * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1852
-     */
1853
-    public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null)
1854
-    {
1855
-        // validate
1856
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1857
-
1858
-        // build parameters
1859
-        if ($id != null) $parameters['id'] = (string)$id;
1860
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1861
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1862
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1863
-
1864
-        // make the call
1865
-        return (array)$this->doCall('friends/ids.json', $parameters);
1866
-    }
1867
-
1868
-    /**
1869
-     * Returns an array of numeric IDs for every user following the specified user.
1870
-     *
1871
-     *
1872
-     * @param null $id
1873
-     * @param null $userId
1874
-     * @param null $screenName
1875
-     * @param null $cursor
1876
-     * @return array
1877
-     * @throws TwitterException
1878
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1879
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1880
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1881
-     * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1882
-     */
1883
-    public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null)
1884
-    {
1885
-        // validate
1886
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1887
-
1888
-        // build parameters
1889
-        if ($id != null) $parameters['id'] = (string)$id;
1890
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1891
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1892
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1893
-
1894
-        // make the call
1895
-        return (array)$this->doCall('followers/ids.json', $parameters);
1896
-    }
1897
-
1898
-
1899
-    // Account resources
1900
-    /**
1901
-     * Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
1902
-     *
1903
-     * @return    array
1904
-     */
1905
-    public function accountVerifyCredentials()
1906
-    {
1907
-        // make the call
1908
-        return (array)$this->doCall('account/verify_credentials.json', null, true);
1909
-    }
1910
-
1911
-    /**
1912
-     *
1913
-     * @return    array
1914
-     */
1915
-    public function accountRateLimitStatus()
1916
-    {
1917
-        // make the call
1918
-        return (array)$this->doCall('account/rate_limit_status.json', null);
1919
-    }
1920
-
1921
-    /**
1922
-     * Ends the session of the authenticating user, returning a null cookie. Use this method to sign users out of client-facing applications like widgets.
1923
-     * @return bool
1924
-     * @throws TwitterException
1925
-     */
1926
-    public function accountEndSession()
1927
-    {
1928
-        try {
1929
-            // make the call
1930
-            $this->doCall('account/end_session.json', null, true, 'POST');
1931
-        } // catch exceptions
1932
-        catch (TwitterException $e) {
1933
-            if ($e->getMessage() === 'Logged out.') {
1934
-                return true;
1935
-            } else throw $e;
1936
-        }
1937
-    }
1938
-
1939
-    /**
1940
-     * Sets which device Twitter delivers updates to for the authenticating user. Sending none as the device parameter will disable IM or SMS updates.
1941
-     *
1942
-     * @return    array
1943
-     * @param    string $device Delivery device type to send updates to.
1944
-     */
1945
-    public function accountUpdateDeliveryDevices($device)
1946
-    {
1947
-        // build parameters
1948
-        $parameters['device'] = (string)$device;
1949
-
1950
-        // make the call
1951
-        return (array)$this->doCall('account/update_delivery_device.json', $parameters, true, 'POST');
1952
-    }
1953
-
1954
-    /**
1955
-     * Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
1956
-     * Each parameter's value must be a valid hexidecimal value, and may be either three or six characters (ex: #fff or #ffffff).
1957
-     *
1958
-     *
1959
-     * @param null $profileBackgroundColor
1960
-     * @param null $profileTextColor
1961
-     * @param null $profileLinkColor
1962
-     * @param null $profileSidebarFillColor
1963
-     * @param null $profileSidebarBorderColor
1964
-     * @return array
1965
-     * @throws TwitterException
1966
-     * @internal param $string [optional] $profileBackgroundColor        Profile background color.
1967
-     * @internal param $string [optional] $profileTextColor                Profile text color.
1968
-     * @internal param $string [optional] $profileLinkColor                Profile link color.
1969
-     * @internal param $string [optional] $profileSidebarFillColor        Profile sidebar's background color.
1970
-     * @internal param $string [optional] $profileSidebarBorderColor        Profile sidebar's border color.
1971
-     */
1972
-    public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null)
1973
-    {
1974
-        // validate
1975
-        if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == ''
1976
-            && $profileSidebarBorderColor == ''
1977
-        ) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
1978
-
1979
-        // build parameters
1980
-        if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor;
1981
-        if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor;
1982
-        if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor;
1983
-        if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
1984
-        if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
1985
-
1986
-        // make the call
1987
-        return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
1988
-    }
1989
-
1990
-    /**
1991
-     * Updates the authenticating user's profile image.
1992
-     *
1993
-     *
1994
-     * @param    string $image The path to the avatar image for the profile. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.
1995
-     * @return array
1996
-     * @throws TwitterException
1997
-     */
1998
-    public function accountUpdateProfileImage($image)
1999
-    {
2000
-        throw new TwitterException('Not implemented');
2001
-
2002
-        // validate
2003
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2004
-
2005
-        // make the call
2006
-        return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
2007
-    }
2008
-
2009
-    /**
2010
-     * Updates the authenticating user's profile background image.
2011
-     *
2012
-     *
2013
-     * @param    string $image The path to the background image for the profile. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forceably scaled down.
2014
-     * @param    bool   $tile  Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
2015
-     * @return array
2016
-     * @throws TwitterException
2017
-     */
2018
-    public function accountUpdateProfileBackgroundImage($image, $tile = false)
2019
-    {
2020
-        throw new TwitterException('Not implemented');
2021
-
2022
-        // validate
2023
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2024
-
2025
-        // build parameters
2026
-        if ($tile) $parameters['tile'] = 'true';
2027
-
2028
-        // make the call
2029
-        return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
2030
-    }
2031
-
2032
-    /**
2033
-     * Sets values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated.
2034
-     *
2035
-     * @return    array
2036
-     * @param    string [optional] $name            Full name associated with the profile. Maximum of 20 characters.
2037
-     * @param    string [optional] $url            URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
2038
-     * @param    string [optional] $location        The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
2039
-     * @param    string [optional] $description    A description of the user owning the account. Maximum of 160 characters.
2040
-     */
2041
-    public function accountUpdateProfile($name = null, $url = null, $location = null, $description = null)
2042
-    {
2043
-        // build parameters
2044
-        $parameters = null;
2045
-        if ($name != null) $parameters['name'] = (string)$name;
2046
-        if ($url != null) $parameters['url'] = (string)$url;
2047
-        if ($location != null) $parameters['location'] = (string)$location;
2048
-        if ($description != null) $parameters['description'] = (string)$description;
2049
-
2050
-        // make the call
2051
-        return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST');
2052
-    }
2053
-
2054
-
2055
-    // Favorites resources
2056
-    /**
2057
-     * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
2058
-     *
2059
-     * @return    array
2060
-     * @param    string [optional] $id    Specifies the ID or screen name of the user for whom to return results for.
2061
-     * @param    int    [optional] $page        Specifies the page of results to retrieve.
2062
-     */
2063
-    public function favorites($id = null, $page = null)
2064
-    {
2065
-        // build parameters
2066
-        $parameters = null;
2067
-        if ($id != null) $parameters['id'] = (string)$id;
2068
-        if ($page != null) $parameters['page'] = (int)$page;
2069
-
2070
-        // make the call
2071
-        return (array)$this->doCall('favorites.json', $parameters, true);
2072
-    }
2073
-
2074
-    /**
2075
-     * Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.
2076
-     *
2077
-     * @return    array
2078
-     * @param    string $id The numerical ID of the desired status.
2079
-     */
2080
-    public function favoritesCreate($id)
2081
-    {
2082
-        // make the call
2083
-        return (array)$this->doCall('favorites/create/' . $id . '.json', null, true, 'POST');
2084
-    }
2085
-
2086
-    /**
2087
-     * Un-favorites the status specified in the ID parameter as the authenticating user. Returns the un-favorited status in the requested format when successful.
2088
-     *
2089
-     * @return    array
2090
-     * @param    string $id The numerical ID of the desired status.
2091
-     */
2092
-    public function favoritesDestroy($id)
2093
-    {
2094
-        // make the call
2095
-        return (array)$this->doCall('favorites/destroy/' . $id . '.json', null, true, 'POST');
2096
-    }
2097
-
2098
-
2099
-    // Notification resources
2100
-    /**
2101
-     * Enables device notifications for updates from the specified user. Returns the specified user when successful.
2102
-     *
2103
-     *
2104
-     * @param null $id
2105
-     * @param null $userId
2106
-     * @param null $screenName
2107
-     * @return array
2108
-     * @throws TwitterException
2109
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2110
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2111
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2112
-     */
2113
-    public function notificationsFollow($id = null, $userId = null, $screenName = null)
2114
-    {
2115
-        // validate
2116
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2117
-
2118
-        // build parameters
2119
-        if ($id != null) $parameters['id'] = (string)$id;
2120
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2121
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2122
-
2123
-        // make the call
2124
-        return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST');
2125
-    }
2126
-
2127
-    /**
2128
-     * Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
2129
-     *
2130
-     *
2131
-     * @param null $id
2132
-     * @param null $userId
2133
-     * @param null $screenName
2134
-     * @return array
2135
-     * @throws TwitterException
2136
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2137
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2138
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2139
-     */
2140
-    public function notificationsLeave($id = null, $userId = null, $screenName = null)
2141
-    {
2142
-        // validate
2143
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2144
-
2145
-        // build parameters
2146
-        if ($id != null) $parameters['id'] = (string)$id;
2147
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2148
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2149
-
2150
-        // make the call
2151
-        return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST');
2152
-    }
2153
-
2154
-
2155
-    // Block resources
2156
-    /**
2157
-     * Blocks the user specified in the ID parameter as the authenticating user. Destroys a friendship to the blocked user if it exists. Returns the blocked user in the requested format when successful.
2158
-     *
2159
-     *
2160
-     * @param null $id
2161
-     * @param null $userId
2162
-     * @param null $screenName
2163
-     * @return array
2164
-     * @throws TwitterException
2165
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2166
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2167
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2168
-     */
2169
-    public function blocksCreate($id = null, $userId = null, $screenName = null)
2170
-    {
2171
-        // validate
2172
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2173
-
2174
-        // build parameters
2175
-        if ($id != null) $parameters['id'] = (string)$id;
2176
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2177
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2178
-
2179
-        // make the call
2180
-        return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST');
2181
-    }
2182
-
2183
-    /**
2184
-     * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2185
-     *
2186
-     *
2187
-     * @param null $id
2188
-     * @param null $userId
2189
-     * @param null $screenName
2190
-     * @return array
2191
-     * @throws TwitterException
2192
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2193
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2194
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2195
-     */
2196
-    public function blocksDestroy($id = null, $userId = null, $screenName = null)
2197
-    {
2198
-        // validate
2199
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2200
-
2201
-        // build parameters
2202
-        if ($id != null) $parameters['id'] = (string)$id;
2203
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2204
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2205
-
2206
-        // make the call
2207
-        return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST');
2208
-    }
2209
-
2210
-    /**
2211
-     * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2212
-     *
2213
-     *
2214
-     * @param null $id
2215
-     * @param null $userId
2216
-     * @param null $screenName
2217
-     * @return mixed
2218
-     * @throws TwitterException
2219
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2220
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2221
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2222
-     */
2223
-    public function blocksExists($id = null, $userId = null, $screenName = null)
2224
-    {
2225
-        // validate
2226
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2227
-
2228
-        // build parameters
2229
-        if ($id != null) $parameters['id'] = (string)$id;
2230
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2231
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2232
-
2233
-        try {
2234
-            // make the call
2235
-            return (array)$this->doCall('blocks/exists.json', $parameters, true);
2236
-        } // catch exceptions
2237
-        catch (TwitterException $e) {
2238
-            if ($e->getMessage() === 'You are not blocking this user.') {
2239
-                return false;
2240
-            } else throw $e;
2241
-        }
2242
-    }
2243
-
2244
-    /**
2245
-     * Returns an array of user objects that the authenticating user is blocking.
2246
-     *
2247
-     * @return    array
2248
-     * @param    int [optional] $page        Specifies the page of results to retrieve. Note: there are pagination limits. See the FAQ for details.
2249
-     */
2250
-    public function blocksBlocking($page = null)
2251
-    {
2252
-        // build parameters
2253
-        $parameters = null;
2254
-        if ($page != null) $parameters['page'] = (int)$page;
2255
-
2256
-        // make the call
2257
-        return (array)$this->doCall('blocks/blocking.json', $parameters, true);
2258
-    }
2259
-
2260
-    /**
2261
-     * Returns an array of numeric user ids the authenticating user is blocking.
2262
-     *
2263
-     * @return    array
2264
-     */
2265
-    public function blocksBlockingIds()
2266
-    {
2267
-        // make the call
2268
-        return (array)$this->doCall('blocks/blocking/ids.json', null, true);
2269
-    }
2270
-
2271
-
2272
-    // Spam Reporting resources
2273
-    /**
2274
-     * The user specified in the id is blocked by the authenticated user and reported as a spammer.
2275
-     *
2276
-     *
2277
-     * @param null $id
2278
-     * @param null $userId
2279
-     * @param null $screenName
2280
-     * @return array
2281
-     * @throws TwitterException
2282
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2283
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2284
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2285
-     */
2286
-    public function reportSpam($id = null, $userId = null, $screenName = null)
2287
-    {
2288
-        // validate
2289
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2290
-
2291
-        // build parameters
2292
-        if ($id != null) $parameters['id'] = (string)$id;
2293
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2294
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2295
-
2296
-        // make the call
2297
-        return (array)$this->doCall('report_spam.json', $parameters, true, 'POST');
2298
-    }
2299
-
2300
-
2301
-    // Saved Searches resources
2302
-    /**
2303
-     * Returns the authenticated user's saved search queries.
2304
-     *
2305
-     * @return    array
2306
-     */
2307
-    public function savedSearches()
2308
-    {
2309
-        // make the call
2310
-        return (array)$this->doCall('saved_searches.json', null, true);
2311
-    }
2312
-
2313
-    /**
2314
-     * Retrieve the data for a saved search owned by the authenticating user specified by the given id.
2315
-     *
2316
-     * @return    array
2317
-     * @param    string $id The ID of the desired saved search.
2318
-     */
2319
-    public function savedSearchesShow($id)
2320
-    {
2321
-        // build parameters
2322
-        $parameters['id'] = (string)$id;
2323
-
2324
-        // make the call
2325
-        return (array)$this->doCall('saved_searches/show.json', $parameters, true);
2326
-    }
2327
-
2328
-    /**
2329
-     * Creates a saved search for the authenticated user.
2330
-     *
2331
-     * @return    array
2332
-     * @param    string $query The query of the search the user would like to save.
2333
-     */
2334
-    public function savedSearchesCreate($query)
2335
-    {
2336
-        // build parameters
2337
-        $parameters['query'] = (string)$query;
2338
-
2339
-        // make the call
2340
-        return (array)$this->doCall('saved_searches/create.json', $parameters, true, 'POST');
2341
-    }
2342
-
2343
-    /**
2344
-     * Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
2345
-     * REMARK: This method seems not to work    @later
2346
-     *
2347
-     * @return    array
2348
-     * @param    string $id The ID of the desired saved search.
2349
-     */
2350
-    public function savedSearchesDestroy($id)
2351
-    {
2352
-        return (array)$this->doCall('saved_searches/destroy/' . (string)$id . '.json', null, true, 'POST');
2353
-    }
2354
-
2355
-
2356
-    // OAuth resources
2357
-    /**
2358
-     * Allows a Consumer application to obtain an OAuth Request Token to request user authorization.
2359
-     * This method fulfills Secion 6.1 of the OAuth 1.0 authentication flow.
2360
-     *
2361
-     *
2362
-     * @param    string $callbackURL
2363
-     * @return array An array containg the token and the secret
2364
-     * @throws TwitterException
2365
-     */
2366
-    public function oAuthRequestToken($callbackURL = null)
2367
-    {
2368
-        // init var
2369
-        $parameters = array();
2370
-
2371
-        // set callback
2372
-        if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL;
2373
-
2374
-        // make the call
2375
-        $response = $this->doOAuthCall('request_token', $parameters);
2376
-
2377
-        // validate
2378
-        if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response)));
2379
-
2380
-        // set some properties
2381
-        if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2382
-        if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2383
-
2384
-        // return
2385
-        return $response;
2386
-    }
2387
-
2388
-    /**
2389
-     * Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token.
2390
-     * This method fulfills Secion 6.3 of the OAuth 1.0 authentication flow.
2391
-     *
2392
-     * @return    array
2393
-     * @param    string $token
2394
-     * @param    string $verifier
2395
-     */
2396
-    public function oAuthAccessToken($token, $verifier)
2397
-    {
2398
-        // init var
2399
-        $parameters                   = array();
2400
-        $parameters['oauth_token']    = (string)$token;
2401
-        $parameters['oauth_verifier'] = (string)$verifier;
2402
-
2403
-        // make the call
2404
-        $response = $this->doOAuthCall('access_token', $parameters);
2405
-
2406
-        // set some properties
2407
-        if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2408
-        if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2409
-
2410
-        // return
2411
-        return $response;
2412
-    }
2413
-
2414
-    /**
2415
-     * Will redirect to the page to authorize the applicatione
2416
-     *
2417
-     * @return    void
2418
-     */
2419
-    public function oAuthAuthorize()
2420
-    {
2421
-        header('Location: ' . self::SECURE_API_URL . '/oauth/authorize?oauth_token=' . $this->oAuthToken);
2422
-    }
2423
-
2424
-    /**
2425
-     * Allows a Consumer application to use an OAuth request_token to request user authorization. This method is a replacement fulfills Secion 6.2 of the OAuth 1.0 authentication flow for applications using the Sign in with Twitter authentication flow. The method will use the currently logged in user as the account to for access authorization unless the force_login parameter is set to true
2426
-     * REMARK: This method seems not to work    @later
2427
-     *
2428
-     * @return    void
2429
-     */
2430
-    public function oAuthAuthenticate()
2431
-    {
2432
-        // make the call
2433
-        return $this->doOAuthCall('authenticate');
2434
-    }
2435
-
2436
-
2437
-    // Local Trends resources
2438
-    /**
2439
-     * Returns the locations that Twitter has trending topic information for.
2440
-     * The response is an array of "locations" that encode the location's WOEID (a Yahoo! Where On Earth ID) and some other human-readable information such as a canonical name and country the location belongs in.
2441
-     * The WOEID that is returned in the location object is to be used when querying for a specific trend.
2442
-     *
2443
-     * @return    array
2444
-     * @param    float [optional] $lat    If passed in conjunction with long, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2445
-     * @param    float [optional] $long    If passed in conjunction with lat, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2446
-     */
2447
-    public function trendsAvailable($lat = null, $long = null)
2448
-    {
2449
-        // build parameters
2450
-        $parameters = null;
2451
-        if ($lat != null) $parameters['lat_for_trends'] = (float)$lat;
2452
-        if ($long != null) $parameters['long_for_trends'] = (float)$long;
2453
-
2454
-        // make the call
2455
-        return (array)$this->doCall('trends/available.json', $parameters);
2456
-    }
2457
-
2458
-    /**
2459
-     * Returns the top 10 trending topics for a specific location Twitter has trending topic information for.
2460
-     * The response is an array of "trend" objects that encode the name of the trending topic, the query parameter that can be used to search for the topic on Search, and the direct URL that can be issued against Search.
2461
-     * This information is cached for five minutes, and therefore users are discouraged from querying these endpoints faster than once every five minutes. Global trends information is also available from this API by using a WOEID of 1.
2462
-     * REMARK: This method seems not to work    @later
2463
-     *
2464
-     * @return    array
2465
-     * @param    string $woeid The WOEID of the location to be querying for.
2466
-     */
2467
-    public function trendsLocation($woeid)
2468
-    {
2469
-        // make the call
2470
-        return (array)$this->doCall('trends/location/' . (string)$woeid . '.json');
2471
-    }
2472
-
2473
-
2474
-    // Geo resources
2475
-    /**
2476
-     * Search for places (cities and neighborhoods) that can be attached to a statuses/update. Given a latitude and a longitude, return a list of all the valid places that can be used as a place_id when updating a status.
2477
-     * Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location up with a call to statuses/update.
2478
-     * There are multiple granularities of places that can be returned -- "neighborhoods", "cities", etc. At this time, only United States data is available through this method.
2479
-     * This API call is meant to be an informative call and will deliver generalized results about geography.
2480
-     *
2481
-     * @return    array
2482
-     * @param    float $lat   The location's latitude that this tweet refers to.
2483
-     * @param    float $long  The location's longitude that this tweet refers to.
2484
-     * @param          string [optional] $accuracy        A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
2485
-     * @param          string [optional] $granularity    The minimal granularity of data to return. If this is not passed in, then neighborhood is assumed. city can also be passed.
2486
-     * @param          int    [optional] $maxResults        A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
2487
-     */
2488
-    public function geoReverseGeoCode($lat, $long, $accuracy = null, $granularity = null, $maxResults = null)
2489
-    {
2490
-        // build parameters
2491
-        $parameters['lat']  = (float)$lat;
2492
-        $parameters['long'] = (float)$long;
2493
-        if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy;
2494
-        if ($granularity != null) $parameters['granularity'] = (string)$granularity;
2495
-        if ($maxResults != null) $parameters['max_results'] = (int)$maxResults;
2496
-
2497
-        // make the call
2498
-        return (array)$this->doCall('geo/reverse_geocode.json', $parameters);
2499
-    }
2500
-
2501
-    /**
2502
-     * Find out more details of a place that was returned from the geo/reverse_geocode method.
2503
-     *
2504
-     * @return    array
2505
-     * @param    string $id
2506
-     * @param           string [optional] $placeId    A place in the world. These IDs can be retrieved from geo/reverse_geocode.
2507
-     */
2508
-    public function geoId($id, $placeId = null)
2509
-    {
2510
-        // build parameters
2511
-        $parameters = null;
2512
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
2513
-
2514
-        // make the call
2515
-        return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters);
2516
-    }
2517
-
2518
-
2519
-    // Help resources
2520
-    /**
2521
-     * Test
2522
-     * REMARK: this methods seems not to work, so don't rely on it
2523
-     *
2524
-     * @return    bool
2525
-     */
2526
-    public function helpTest()
2527
-    {
2528
-        // make the call
2529
-        return ($this->doCall('help/test', null, null, 'GET', null, false) == 'ok');
2530
-    }
44
+	// internal constant to enable/disable debugging
45
+	const DEBUG = false;
46
+
47
+	// url for the twitter-api
48
+	const API_URL        = 'https://api.twitter.com/1';
49
+	const SECURE_API_URL = 'https://api.twitter.com';
50
+
51
+	// port for the twitter-api
52
+	const API_PORT        = 443;
53
+	const SECURE_API_PORT = 443;
54
+
55
+	// current version
56
+	const VERSION = '2.0.1';
57
+
58
+	/**
59
+	 * A cURL instance
60
+	 *
61
+	 * @var    resource
62
+	 */
63
+	private $curl;
64
+
65
+	/**
66
+	 * The consumer key
67
+	 *
68
+	 * @var    string
69
+	 */
70
+	private $consumerKey;
71
+
72
+	/**
73
+	 * The consumer secret
74
+	 *
75
+	 * @var    string
76
+	 */
77
+	private $consumerSecret;
78
+
79
+	/**
80
+	 * The oAuth-token
81
+	 *
82
+	 * @var    string
83
+	 */
84
+	private $oAuthToken = '';
85
+
86
+	/**
87
+	 * The oAuth-token-secret
88
+	 *
89
+	 * @var    string
90
+	 */
91
+	private $oAuthTokenSecret = '';
92
+
93
+	/**
94
+	 * The timeout
95
+	 *
96
+	 * @var    int
97
+	 */
98
+	private $timeOut = 60;
99
+
100
+	/**
101
+	 * The user agent
102
+	 *
103
+	 * @var    string
104
+	 */
105
+	private $userAgent;
106
+
107
+	// class methods
108
+	/**
109
+	 * Default constructor
110
+	 *
111
+	 *
112
+	 * @param    string $consumerKey    The consumer key to use.
113
+	 * @param    string $consumerSecret The consumer secret to use.
114
+	 */
115
+	public function __construct($consumerKey, $consumerSecret)
116
+	{
117
+		$this->setConsumerKey($consumerKey);
118
+		$this->setConsumerSecret($consumerSecret);
119
+	}
120
+
121
+	/**
122
+	 * Default destructor
123
+	 *
124
+	 * @return    void
125
+	 */
126
+	public function __destruct()
127
+	{
128
+		if ($this->curl != null) curl_close($this->curl);
129
+	}
130
+
131
+	/**
132
+	 * Format the parameters as a querystring
133
+	 *
134
+	 * @return    string
135
+	 * @param    array $parameters
136
+	 */
137
+	private function buildQuery(array $parameters)
138
+	{
139
+		// no parameters?
140
+		if (empty($parameters)) return '';
141
+
142
+		// encode the keys
143
+		$keys = self::urlencode_rfc3986(array_keys($parameters));
144
+
145
+		// encode the values
146
+		$values = self::urlencode_rfc3986(array_values($parameters));
147
+
148
+		// reset the parameters
149
+		$parameters = array_combine($keys, $values);
150
+
151
+		// sort parameters by key
152
+		uksort($parameters, 'strcmp');
153
+
154
+		// loop parameters
155
+		foreach ($parameters as $key => $value) {
156
+			// sort by value
157
+			if (is_array($value)) $parameters[$key] = natsort($value);
158
+		}
159
+
160
+		// process parameters
161
+		foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value);
162
+
163
+		// return
164
+		return implode('&', $chunks);
165
+	}
166
+
167
+	/**
168
+	 * All OAuth 1.0 requests use the same basic algorithm for creating a signature base string and a signature.
169
+	 * The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed,
170
+	 * complete with path (but not query parameters), followed by an ampersand ("&").
171
+	 * Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored),
172
+	 * including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and
173
+	 * then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for each parameter are URL encoded in isolation.
174
+	 * Instead of using the equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then joined by the
175
+	 * URL-escaped ampersand sign, "%26".
176
+	 *
177
+	 * @return    string
178
+	 * @param    string $url
179
+	 * @param    string $method
180
+	 * @param    array  $parameters
181
+	 */
182
+	private function calculateBaseString($url, $method, array $parameters)
183
+	{
184
+		// redefine
185
+		$url        = (string)$url;
186
+		$parameters = (array)$parameters;
187
+
188
+		// init var
189
+		$pairs  = array();
190
+		$chunks = array();
191
+
192
+		// sort parameters by key
193
+		uksort($parameters, 'strcmp');
194
+
195
+		// loop parameters
196
+		foreach ($parameters as $key => $value) {
197
+			// sort by value
198
+			if (is_array($value)) $parameters[$key] = natsort($value);
199
+		}
200
+
201
+		// process queries
202
+		foreach ($parameters as $key => $value) {
203
+			$chunks[] = self::urlencode_rfc3986($key) . '%3D' . self::urlencode_rfc3986($value);
204
+		}
205
+
206
+		// buils base
207
+		$base = $method . '&';
208
+		$base .= urlencode($url) . '&';
209
+		$base .= implode('%26', $chunks);
210
+
211
+		// return
212
+		return $base;
213
+	}
214
+
215
+	/**
216
+	 * Build the Authorization header
217
+	 * @later: fix me
218
+	 *
219
+	 *
220
+	 * @param    array $parameters
221
+	 * @param null     $url
222
+	 * @return string
223
+	 */
224
+	private function calculateHeader(array $parameters, $url = null)
225
+	{
226
+		// redefine
227
+		$url = (string)$url;
228
+
229
+		// divide into parts
230
+		$parts = parse_url($url);
231
+
232
+		// init var
233
+		$chunks = array();
234
+
235
+		// process queries
236
+		foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
237
+
238
+		// build return
239
+		$return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
240
+		$return .= implode(',', $chunks);
241
+
242
+		// prepend name and OAuth part
243
+		return $return;
244
+	}
245
+
246
+	/**
247
+	 * Make an call to the oAuth
248
+	 * @todo    refactor me
249
+	 *
250
+	 *
251
+	 * @param    string $method
252
+	 * @param array     $parameters [optional] $parameters
253
+	 * @return array
254
+	 * @throws TwitterException
255
+	 */
256
+	private function doOAuthCall($method, array $parameters = null)
257
+	{
258
+		// redefine
259
+		$method = (string)$method;
260
+
261
+		// append default parameters
262
+		$parameters['oauth_consumer_key']     = $this->getConsumerKey();
263
+		$parameters['oauth_nonce']            = md5(microtime() . rand());
264
+		$parameters['oauth_timestamp']        = time();
265
+		$parameters['oauth_signature_method'] = 'HMAC-SHA1';
266
+		$parameters['oauth_version']          = '1.0';
267
+
268
+		// calculate the base string
269
+		$base = $this->calculateBaseString(self::SECURE_API_URL . '/oauth/' . $method, 'POST', $parameters);
270
+
271
+		// add sign into the parameters
272
+		$parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
273
+
274
+		// calculate header
275
+		$header = $this->calculateHeader($parameters, self::SECURE_API_URL . '/oauth/' . $method);
276
+
277
+		// set options
278
+		$options[CURLOPT_URL]            = self::SECURE_API_URL . '/oauth/' . $method;
279
+		$options[CURLOPT_PORT]           = self::SECURE_API_PORT;
280
+		$options[CURLOPT_USERAGENT]      = $this->getUserAgent();
281
+		$options[CURLOPT_FOLLOWLOCATION] = true;
282
+		$options[CURLOPT_RETURNTRANSFER] = true;
283
+		$options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
284
+		$options[CURLOPT_SSL_VERIFYPEER] = false;
285
+		$options[CURLOPT_SSL_VERIFYHOST] = false;
286
+		$options[CURLOPT_HTTPHEADER]     = array('Expect:');
287
+		$options[CURLOPT_POST]           = 1;
288
+		$options[CURLOPT_POSTFIELDS]     = $this->buildQuery($parameters);
289
+
290
+		// init
291
+		if ($this->curl == null) $this->curl = curl_init();
292
+
293
+		// set options
294
+		curl_setopt_array($this->curl, $options);
295
+
296
+		// execute
297
+		$response = curl_exec($this->curl);
298
+		$headers  = curl_getinfo($this->curl);
299
+
300
+		// fetch errors
301
+		$errorNumber  = curl_errno($this->curl);
302
+		$errorMessage = curl_error($this->curl);
303
+
304
+		// error?
305
+		if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber);
306
+
307
+		// init var
308
+		$return = array();
309
+
310
+		// parse the string
311
+		parse_str($response, $return);
312
+
313
+		// return
314
+		return $return;
315
+	}
316
+
317
+	/**
318
+	 * Make the call
319
+	 *
320
+	 *
321
+	 * @param    string $url
322
+	 * @param array     $parameters
323
+	 * @param bool      $authenticate
324
+	 * @param string    $method
325
+	 * @param null      $filePath
326
+	 * @param bool      $expectJSON
327
+	 * @return string
328
+	 * @throws TwitterException
329
+	 * @internal param $array [optiona] $aParameters
330
+	 * @internal param $bool [optional] $authenticate
331
+	 * @internal param $bool [optional] $usePost
332
+	 */
333
+	private function doCall($url, array $parameters = null, $authenticate = false, $method = 'GET', $filePath = null, $expectJSON = true)
334
+	{
335
+		// allowed methods
336
+		$allowedMethods = array('GET', 'POST');
337
+
338
+		// redefine
339
+		$url          = (string)$url;
340
+		$parameters   = (array)$parameters;
341
+		$authenticate = (bool)$authenticate;
342
+		$method       = (string)$method;
343
+		$expectJSON   = (bool)$expectJSON;
344
+
345
+		// validate method
346
+		if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
347
+
348
+		// append default parameters
349
+		$oauth['oauth_consumer_key']     = $this->getConsumerKey();
350
+		$oauth['oauth_nonce']            = md5(microtime() . rand());
351
+		$oauth['oauth_timestamp']        = time();
352
+		$oauth['oauth_token']            = $this->getOAuthToken();
353
+		$oauth['oauth_signature_method'] = 'HMAC-SHA1';
354
+		$oauth['oauth_version']          = '1.0';
355
+
356
+		// set data
357
+		$data = $oauth;
358
+		if (!empty($parameters)) $data = array_merge($data, $parameters);
359
+
360
+		// calculate the base string
361
+		$base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data);
362
+
363
+		// add sign into the parameters
364
+		$oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
365
+
366
+		$headers[] = $this->calculateHeader($oauth, self::API_URL . '/' . $url);
367
+		$headers[] = 'Expect:';
368
+
369
+		// based on the method, we should handle the parameters in a different way
370
+		if ($method === 'POST') {
371
+			// file provided?
372
+			if ($filePath != null) {
373
+				// build a boundary
374
+				$boundary = md5(time());
375
+
376
+				// process file
377
+				$fileInfo = pathinfo($filePath);
378
+
379
+				// set mimeType
380
+				$mimeType = 'application/octet-stream';
381
+				if ($fileInfo['extension'] === 'jpg' || $fileInfo['extension'] === 'jpeg') {
382
+					$mimeType = 'image/jpeg';
383
+				} elseif ($fileInfo['extension'] === 'gif') $mimeType = 'image/gif';
384
+				elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png';
385
+
386
+				// init var
387
+				$content = '--' . $boundary . "\r\n";
388
+
389
+				// set file
390
+				$content = 'Content-Disposition: form-data; name="image";filename="' . $fileInfo['basename'] . '"' . "\r\n" . 'Content-Type: ' . $mimeType . "\r\n\r\n" . file_get_contents($filePath) . "\r\n--" . $boundary . "\r\n";
391
+
392
+				// build headers
393
+				$headers[] = 'Content-Type: multipart/form-data; boundary=' . $boundary;
394
+				$headers[] = 'Content-Length: ' . strlen($content);
395
+
396
+				// set content
397
+				$options[CURLOPT_POSTFIELDS] = $content;
398
+			} // no file
399
+			else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
400
+
401
+			// enable post
402
+			$options[CURLOPT_POST] = 1;
403
+		} else {
404
+			// add the parameters into the querystring
405
+			if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters);
406
+		}
407
+
408
+		// set options
409
+		$options[CURLOPT_URL]            = self::API_URL . '/' . $url;
410
+		$options[CURLOPT_PORT]           = self::API_PORT;
411
+		$options[CURLOPT_USERAGENT]      = $this->getUserAgent();
412
+		$options[CURLOPT_FOLLOWLOCATION] = true;
413
+		$options[CURLOPT_RETURNTRANSFER] = true;
414
+		$options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
415
+		$options[CURLOPT_SSL_VERIFYPEER] = false;
416
+		$options[CURLOPT_SSL_VERIFYHOST] = false;
417
+		$options[CURLOPT_HTTP_VERSION]   = CURL_HTTP_VERSION_1_1;
418
+		$options[CURLOPT_HTTPHEADER]     = $headers;
419
+
420
+		// init
421
+		if ($this->curl == null) $this->curl = curl_init();
422
+
423
+		// set options
424
+		curl_setopt_array($this->curl, $options);
425
+
426
+		// execute
427
+		$response = curl_exec($this->curl);
428
+		$headers  = curl_getinfo($this->curl);
429
+
430
+		// fetch errors
431
+		$errorNumber  = curl_errno($this->curl);
432
+		$errorMessage = curl_error($this->curl);
433
+
434
+		// we don't expext JSON, return the response
435
+		if (!$expectJSON) return $response;
436
+
437
+		// replace ids with their string values, added because of some PHP-version can't handle these large values
438
+		$response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
439
+
440
+		// we expect JSON, so decode it
441
+		$json = @json_decode($response, true);
442
+
443
+		// validate JSON
444
+		if ($json === null) {
445
+			// should we provide debug information
446
+			if (self::DEBUG) {
447
+				// make it output proper
448
+				echo '<pre>';
449
+
450
+				// dump the header-information
451
+				var_dump($headers);
452
+
453
+				// dump the error
454
+				var_dump($errorMessage);
455
+
456
+				// dump the raw response
457
+				var_dump($response);
458
+
459
+				// end proper format
460
+				echo '</pre>';
461
+			}
462
+
463
+			// throw exception
464
+			throw new TwitterException('Invalid response.');
465
+		}
466
+
467
+		// any errors
468
+		if (isset($json['errors'])) {
469
+			// should we provide debug information
470
+			if (self::DEBUG) {
471
+				// make it output proper
472
+				echo '<pre>';
473
+
474
+				// dump the header-information
475
+				var_dump($headers);
476
+
477
+				// dump the error
478
+				var_dump($errorMessage);
479
+
480
+				// dump the raw response
481
+				var_dump($response);
482
+
483
+				// end proper format
484
+				echo '</pre>';
485
+			}
486
+
487
+			// throw exception
488
+			if (isset($json['errors'][0]['message'])) {
489
+				throw new TwitterException($json['errors'][0]['message']);
490
+			} else throw new TwitterException('Invalid response.');
491
+		}
492
+
493
+		// any error
494
+		if (isset($json['error'])) {
495
+			// should we provide debug information
496
+			if (self::DEBUG) {
497
+				// make it output proper
498
+				echo '<pre>';
499
+
500
+				// dump the header-information
501
+				var_dump($headers);
502
+
503
+				// dump the raw response
504
+				var_dump($response);
505
+
506
+				// end proper format
507
+				echo '</pre>';
508
+			}
509
+
510
+			// throw exception
511
+			throw new TwitterException($json['error']);
512
+		}
513
+
514
+		// return
515
+		return $json;
516
+	}
517
+
518
+	/**
519
+	 * Get the consumer key
520
+	 *
521
+	 * @return    string
522
+	 */
523
+	private function getConsumerKey()
524
+	{
525
+		return $this->consumerKey;
526
+	}
527
+
528
+	/**
529
+	 * Get the consumer secret
530
+	 *
531
+	 * @return    string
532
+	 */
533
+	private function getConsumerSecret()
534
+	{
535
+		return $this->consumerSecret;
536
+	}
537
+
538
+	/**
539
+	 * Get the oAuth-token
540
+	 *
541
+	 * @return    string
542
+	 */
543
+	private function getOAuthToken()
544
+	{
545
+		return $this->oAuthToken;
546
+	}
547
+
548
+	/**
549
+	 * Get the oAuth-token-secret
550
+	 *
551
+	 * @return    string
552
+	 */
553
+	private function getOAuthTokenSecret()
554
+	{
555
+		return $this->oAuthTokenSecret;
556
+	}
557
+
558
+	/**
559
+	 * Get the timeout
560
+	 *
561
+	 * @return    int
562
+	 */
563
+	public function getTimeOut()
564
+	{
565
+		return (int)$this->timeOut;
566
+	}
567
+
568
+	/**
569
+	 * Get the useragent that will be used. Our version will be prepended to yours.
570
+	 * It will look like: "PHP Twitter/<version> <your-user-agent>"
571
+	 *
572
+	 * @return    string
573
+	 */
574
+	public function getUserAgent()
575
+	{
576
+		return (string)'PHP Twitter/' . self::VERSION . ' ' . $this->userAgent;
577
+	}
578
+
579
+	/**
580
+	 * Set the consumer key
581
+	 *
582
+	 * @return    void
583
+	 * @param    string $key The consumer key to use.
584
+	 */
585
+	private function setConsumerKey($key)
586
+	{
587
+		$this->consumerKey = (string)$key;
588
+	}
589
+
590
+	/**
591
+	 * Set the consumer secret
592
+	 *
593
+	 * @return    void
594
+	 * @param    string $secret The consumer secret to use.
595
+	 */
596
+	private function setConsumerSecret($secret)
597
+	{
598
+		$this->consumerSecret = (string)$secret;
599
+	}
600
+
601
+	/**
602
+	 * Set the oAuth-token
603
+	 *
604
+	 * @return    void
605
+	 * @param    string $token The token to use.
606
+	 */
607
+	public function setOAuthToken($token)
608
+	{
609
+		$this->oAuthToken = (string)$token;
610
+	}
611
+
612
+	/**
613
+	 * Set the oAuth-secret
614
+	 *
615
+	 * @return    void
616
+	 * @param    string $secret The secret to use.
617
+	 */
618
+	public function setOAuthTokenSecret($secret)
619
+	{
620
+		$this->oAuthTokenSecret = (string)$secret;
621
+	}
622
+
623
+	/**
624
+	 * Set the timeout
625
+	 *
626
+	 * @return    void
627
+	 * @param    int $seconds The timeout in seconds
628
+	 */
629
+	public function setTimeOut($seconds)
630
+	{
631
+		$this->timeOut = (int)$seconds;
632
+	}
633
+
634
+	/**
635
+	 * Get the useragent that will be used. Our version will be prepended to yours.
636
+	 * It will look like: "PHP Twitter/<version> <your-user-agent>"
637
+	 *
638
+	 * @return    void
639
+	 * @param    string $userAgent Your user-agent, it should look like <app-name>/<app-version>
640
+	 */
641
+	public function setUserAgent($userAgent)
642
+	{
643
+		$this->userAgent = (string)$userAgent;
644
+	}
645
+
646
+	/**
647
+	 * Build the signature for the data
648
+	 *
649
+	 * @return    string
650
+	 * @param    string $key  The key to use for signing.
651
+	 * @param    string $data The data that has to be signed.
652
+	 */
653
+	private function hmacsha1($key, $data)
654
+	{
655
+		return base64_encode(hash_hmac('SHA1', $data, $key, true));
656
+	}
657
+
658
+	/**
659
+	 * URL-encode method for internatl use
660
+	 *
661
+	 * @return    string
662
+	 * @param    mixed $value The value to encode.
663
+	 */
664
+	private static function urlencode_rfc3986($value)
665
+	{
666
+		if (is_array($value)) {
667
+			return array_map(array('Twitter', 'urlencode_rfc3986'), $value);
668
+		} else {
669
+			$search  = array('+', ' ', '%7E', '%');
670
+			$replace = array('%20', '%20', '~', '%25');
671
+
672
+			return str_replace($search, $replace, urlencode($value));
673
+		}
674
+	}
675
+
676
+
677
+	// Timeline resources
678
+	/**
679
+	 * Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
680
+	 * The public timeline is cached for 60 seconds and requesting it more often than that is unproductive and a waste of resources.
681
+	 *
682
+	 * @return    array
683
+	 * @param    bool [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
684
+	 */
685
+	public function statusesPublicTimeline($skipUser = false)
686
+	{
687
+		// redefine
688
+		$skipUser = (bool)$skipUser;
689
+
690
+		// build parameters
691
+		$parameters = array();
692
+		if ($skipUser) $parameters['skip_user'] = 'true';
693
+
694
+		// make the call
695
+		return (array)$this->doCall('statuses/public_timeline.json', $parameters);
696
+	}
697
+
698
+	/**
699
+	 * Returns the 20 most recent statuses posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web.
700
+	 *
701
+	 * @return    array
702
+	 * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
703
+	 * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
704
+	 * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
705
+	 * @param    int    [optional] $page            Specifies the page of results to retrieve.
706
+	 * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
707
+	 */
708
+	public function statusesHomeTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
709
+	{
710
+		// redefine
711
+		$skipUser = (bool)$skipUser;
712
+
713
+		// build parameters
714
+		$parameters = array();
715
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
716
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
717
+		if ($count != null) $parameters['count'] = (int)$count;
718
+		if ($page != null) $parameters['page'] = (int)$page;
719
+		if ($skipUser) $parameters['skip_user'] = 'true';
720
+
721
+		// make the call
722
+		return (array)$this->doCall('statuses/home_timeline.json', $parameters, true);
723
+	}
724
+
725
+	/**
726
+	 * Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends.
727
+	 * This is the equivalent of /timeline/home on the Web.
728
+	 *
729
+	 * Usage note: This home_timeline call is identical to statuses/friends_timeline, except that home_timeline also contains retweets, while statuses/friends_timeline does not for backwards compatibility reasons.
730
+	 * In a future version of the API, statuses/friends_timeline will be deprected and replaced by home_timeline.
731
+	 *
732
+	 * @return    array
733
+	 * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
734
+	 * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
735
+	 * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
736
+	 * @param    int    [optional] $page            Specifies the page of results to retrieve.
737
+	 * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
738
+	 */
739
+	public function statusesFriendsTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
740
+	{
741
+		// redefine
742
+		$skipUser = (bool)$skipUser;
743
+
744
+		// build parameters
745
+		$parameters = array();
746
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
747
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
748
+		if ($count != null) $parameters['count'] = (int)$count;
749
+		if ($page != null) $parameters['page'] = (int)$page;
750
+		if ($skipUser) $parameters['skip_user'] = 'true';
751
+
752
+		// make the call
753
+		return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true);
754
+	}
755
+
756
+	/**
757
+	 * Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
758
+	 * This is the equivalent of the Web / page for your own user, or the profile page for a third party.
759
+	 *
760
+	 * For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom).
761
+	 * If you'd like them included, you can merge them in from statuses retweeted_by_me.
762
+	 *
763
+	 * @return    array
764
+	 * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
765
+	 * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
766
+	 * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
767
+	 * @param    string [optional] $sinceId        Returns results with an ID greater than (that is, more recent than) the specified ID.
768
+	 * @param    string [optional] $maxId            Returns results with an ID less than (that is, older than) or equal to the specified ID.
769
+	 * @param    int    [optional] $count            Specifies the number of records to retrieve. May not be greater than 200.
770
+	 * @param    int    [optional] $page                Specifies the page of results to retrieve.
771
+	 * @param    bool   [optional] $skipUser        When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
772
+	 */
773
+	public function statusesUserTimeline($id = null, $userId = null, $screenName = null, $sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
774
+	{
775
+		// redefine
776
+		$skipUser = (bool)$skipUser;
777
+
778
+		// build parameters
779
+		$parameters = array();
780
+		if ($id != null) $parameters['id'] = (string)$id;
781
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
782
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
783
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
784
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
785
+		if ($count != null) $parameters['count'] = (int)$count;
786
+		if ($page != null) $parameters['page'] = (int)$page;
787
+		if ($skipUser) $parameters['skip_user'] = 'true';
788
+
789
+		// make the call
790
+		return (array)$this->doCall('statuses/user_timeline.json', $parameters, true);
791
+	}
792
+
793
+	/**
794
+	 * Returns the 20 most recent mentions (status containing @username) for the authenticating user.
795
+	 *
796
+	 *
797
+	 * @param null $sinceId
798
+	 * @param null $maxId
799
+	 * @param null $count
800
+	 * @param null $page
801
+	 * @return array
802
+	 * @throws TwitterException
803
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
804
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
805
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
806
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
807
+	 */
808
+	public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null)
809
+	{
810
+		// validate
811
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
812
+
813
+		// build parameters
814
+		$parameters = array();
815
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
816
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
817
+		if ($count != null) $parameters['count'] = (int)$count;
818
+		if ($page != null) $parameters['page'] = (int)$page;
819
+
820
+		// make the call
821
+		return (array)$this->doCall('statuses/mentions.json', $parameters);
822
+	}
823
+
824
+	/**
825
+	 * Returns the 20 most recent retweets posted by the authenticating user.
826
+	 *
827
+	 *
828
+	 * @param null $sinceId
829
+	 * @param null $maxId
830
+	 * @param null $count
831
+	 * @param null $page
832
+	 * @return array
833
+	 * @throws TwitterException
834
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
835
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
836
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
837
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
838
+	 */
839
+	public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null)
840
+	{
841
+		// validate
842
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
843
+
844
+		// build parameters
845
+		$parameters = array();
846
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
847
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
848
+		if ($count != null) $parameters['count'] = (int)$count;
849
+		if ($page != null) $parameters['page'] = (int)$page;
850
+
851
+		// make the call
852
+		return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
853
+	}
854
+
855
+	/**
856
+	 * Returns the 20 most recent retweets posted by the authenticating user's friends.
857
+	 *
858
+	 *
859
+	 * @param null $sinceId
860
+	 * @param null $maxId
861
+	 * @param null $count
862
+	 * @param null $page
863
+	 * @return array
864
+	 * @throws TwitterException
865
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
866
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
867
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
868
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
869
+	 */
870
+	public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null)
871
+	{
872
+		// validate
873
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
874
+
875
+		// build parameters
876
+		$parameters = array();
877
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
878
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
879
+		if ($count != null) $parameters['count'] = (int)$count;
880
+		if ($page != null) $parameters['page'] = (int)$page;
881
+
882
+		// make the call
883
+		return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
884
+	}
885
+
886
+
887
+	// Tweets resources
888
+	/**
889
+	 * Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
890
+	 *
891
+	 *
892
+	 * @param null $sinceId
893
+	 * @param null $maxId
894
+	 * @param null $count
895
+	 * @param null $page
896
+	 * @return array
897
+	 * @throws TwitterException
898
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
899
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
900
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
901
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
902
+	 */
903
+	public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null)
904
+	{
905
+		// validate
906
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
907
+
908
+		// build parameters
909
+		$parameters = array();
910
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
911
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
912
+		if ($count != null) $parameters['count'] = (int)$count;
913
+		if ($page != null) $parameters['page'] = (int)$page;
914
+
915
+		// make the call
916
+		return (array)$this->doCall('statuses/retweets_of_me.json', $parameters);
917
+	}
918
+
919
+	/**
920
+	 * Returns a single status, specified by the id parameter below. The status's author will be returned inline.
921
+	 *
922
+	 * @return    array
923
+	 * @param    string $id The numerical ID of the desired status.
924
+	 */
925
+	public function statusesShow($id)
926
+	{
927
+		// build parameters
928
+		$parameters['id'] = (string)$id;
929
+
930
+		// make the call
931
+		return (array)$this->doCall('statuses/show.json', $parameters);
932
+	}
933
+
934
+	/**
935
+	 * Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
936
+	 *
937
+	 * @return    array
938
+	 * @param    string $status The text of your status update, up to 140 characters. URL encode as necessary.
939
+	 * @param           string  [optional] $inReplyToStatusId        The ID of an existing status that the update is in reply to.
940
+	 * @param           float   [optional] $lat                    The location's latitude that this tweet refers to.
941
+	 * @param           float   [optional] $long                    The location's longitude that this tweet refers to.
942
+	 * @param           string  [optional] $placeId                A place in the world. These IDs can be retrieved from geo/reverse_geocode.
943
+	 * @param           bool    [optional] $displayCoordinates        Whether or not to put a pin on the exact coordinates a tweet has been sent from.
944
+	 */
945
+	public function statusesUpdate($status, $inReplyToStatusId = null, $lat = null, $long = null, $placeId = null, $displayCoordinates = false)
946
+	{
947
+		// build parameters
948
+		$parameters['status'] = (string)$status;
949
+		if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
950
+		if ($lat != null) $parameters['lat'] = (float)$lat;
951
+		if ($long != null) $parameters['long'] = (float)$long;
952
+		if ($placeId != null) $parameters['place_id'] = (string)$placeId;
953
+		if ($displayCoordinates) $parameters['display_coordinates'] = 'true';
954
+
955
+		// make the call
956
+		return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST');
957
+	}
958
+
959
+	/**
960
+	 * Destroys the status specified by the required ID parameter.
961
+	 * Usage note: The authenticating user must be the author of the specified status.
962
+	 *
963
+	 * @return    bool
964
+	 * @param    string $id The numerical ID of the desired status.
965
+	 */
966
+	public function statusesDestroy($id)
967
+	{
968
+		// build parameters
969
+		$parameters['id'] = (string)$id;
970
+
971
+		// make the call
972
+		return (array)$this->doCall('statuses/destroy.json', $parameters, true, 'POST');
973
+	}
974
+
975
+	/**
976
+	 * Retweets a tweet. Returns the original tweet with retweet details embedded.
977
+	 *
978
+	 * @return    array
979
+	 * @param    string $id The numerical ID of the desired status.
980
+	 */
981
+	public function statusesRetweet($id)
982
+	{
983
+		// make the call
984
+		return (array)$this->doCall('statuses/retweet/' . $id . '.json', null, true, 'POST');
985
+	}
986
+
987
+	/**
988
+	 * Returns up to 100 of the first retweets of a given tweet.
989
+	 *
990
+	 *
991
+	 * @param    string $id The numerical ID of the desired status.
992
+	 * @param           int [optional] $count    Specifies the number of records to retrieve. May not be greater than 100.
993
+	 * @return array
994
+	 * @throws TwitterException
995
+	 */
996
+	public function statusesRetweets($id, $count = null)
997
+	{
998
+		// validate
999
+		if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.');
1000
+
1001
+		// build parameters
1002
+		$parameters = null;
1003
+		if ($count != null) $parameters['count'] = (int)$count;
1004
+
1005
+		// make the call
1006
+		return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters);
1007
+	}
1008
+
1009
+	/**
1010
+	 * Show user objects of up to 100 members who retweeted the status.
1011
+	 *
1012
+	 *
1013
+	 * @param    string $id The numerical ID of the desired status.
1014
+	 * @param null      $count
1015
+	 * @param null      $page
1016
+	 * @return array
1017
+	 * @throws TwitterException
1018
+	 * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1019
+	 * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1020
+	 */
1021
+	public function statusesIdRetweetedBy($id, $count = null, $page = null)
1022
+	{
1023
+		// validate
1024
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1025
+
1026
+		// build parameters
1027
+		$parameters = null;
1028
+		if ($count != null) $parameters['count'] = (int)$count;
1029
+		if ($page != null) $parameters['page'] = (int)$page;
1030
+
1031
+		// make the call
1032
+		return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true);
1033
+	}
1034
+
1035
+	/**
1036
+	 * Show user ids of up to 100 users who retweeted the status.
1037
+	 *
1038
+	 *
1039
+	 * @param    string $id The numerical ID of the desired status.
1040
+	 * @param null      $count
1041
+	 * @param null      $page
1042
+	 * @return array
1043
+	 * @throws TwitterException
1044
+	 * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1045
+	 * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1046
+	 */
1047
+	public function statusesIdRetweetedByIds($id, $count = null, $page = null)
1048
+	{
1049
+		// validate
1050
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1051
+
1052
+		// build parameters
1053
+		$parameters = null;
1054
+		if ($count != null) $parameters['count'] = (int)$count;
1055
+		if ($page != null) $parameters['page'] = (int)$page;
1056
+
1057
+		// make the call
1058
+		return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true);
1059
+	}
1060
+
1061
+
1062
+	// User resources
1063
+	/**
1064
+	 * Returns extended information of a given user, specified by ID or screen name as per the required id parameter.
1065
+	 * The author's most recent status will be returned inline.
1066
+	 *
1067
+	 *
1068
+	 * @param null $id
1069
+	 * @param null $userId
1070
+	 * @param null $screenName
1071
+	 * @return array
1072
+	 * @throws TwitterException
1073
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1074
+	 * @internal param $string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1075
+	 * @internal param $string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1076
+	 */
1077
+	public function usersShow($id = null, $userId = null, $screenName = null)
1078
+	{
1079
+		// validate
1080
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1081
+
1082
+		// build parameters
1083
+		if ($id != null) $parameters['id'] = (string)$id;
1084
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1085
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1086
+
1087
+		// make the call
1088
+		return (array)$this->doCall('users/show.json', $parameters);
1089
+	}
1090
+
1091
+	/**
1092
+	 * Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.
1093
+	 * The author's most recent status (if the authenticating user has permission) will be returned inline.
1094
+	 *
1095
+	 *
1096
+	 * @param null $userIds
1097
+	 * @param null $screenNames
1098
+	 * @return array
1099
+	 * @throws TwitterException
1100
+	 * @internal param $mixed [optional] $userIds        A comma separated list of user IDs, up to 100 in total.
1101
+	 * @internal param $mixed [optional] $screenNames    A comma separated list of screen names, up to 100 in total.
1102
+	 */
1103
+	public function usersLookup($userIds = null, $screenNames = null)
1104
+	{
1105
+		// redefine
1106
+		$userIds     = (array)$userIds;
1107
+		$screenNames = (array)$screenNames;
1108
+
1109
+		// validate
1110
+		if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
1111
+
1112
+		// build parameters
1113
+		if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds);
1114
+		if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1115
+
1116
+		// make the call
1117
+		return (array)$this->doCall('users/lookup.json', $parameters, true);
1118
+
1119
+	}
1120
+
1121
+	/**
1122
+	 * Run a search for users similar to the Find People button on Twitter.com; the same results returned by people search on Twitter.com will be returned by using this API.
1123
+	 * Usage note: It is only possible to retrieve the first 1000 matches from this API.
1124
+	 *
1125
+	 * @return    array
1126
+	 * @param    string $q  The search query term.
1127
+	 * @param           int [optional] $perPage    Specifies the number of results to retrieve.
1128
+	 * @param           int [optional] $page        Specifies the page of results to retrieve.
1129
+	 */
1130
+	public function usersSearch($q, $perPage = null, $page = null)
1131
+	{
1132
+		// build parameters
1133
+		$parameters['q'] = (string)$q;
1134
+		if ($perPage != null) $parameters['per_page'] = (int)$perPage;
1135
+		if ($page != null) $parameters['page'] = (int)$page;
1136
+
1137
+		// make the call
1138
+		return (array)$this->doCall('users/search.json', $parameters, true);
1139
+
1140
+	}
1141
+
1142
+	/**
1143
+	 * Access to Twitter's suggested user list. This returns the list of suggested user categories. The category can be used in the users/suggestions/category  endpoint to get the users in that category.
1144
+	 *
1145
+	 * @return    array
1146
+	 */
1147
+	public function usersSuggestions()
1148
+	{
1149
+		return (array)$this->doCall('users/suggestions.json', null, true);
1150
+	}
1151
+
1152
+	/**
1153
+	 * Access the users in a given category of the Twitter suggested user list.
1154
+	 * It is recommended that end clients cache this data for no more than one hour.
1155
+	 *
1156
+	 * @return    array
1157
+	 * @param    string $slug The short name of list or a category.
1158
+	 */
1159
+	public function usersSuggestionsSlug($slug)
1160
+	{
1161
+		return (array)$this->doCall('users/suggestions/' . (string)$slug . '.json');
1162
+	}
1163
+
1164
+	/**
1165
+	 * Returns a user's friends, each with current status inline. They are ordered by the order in which the user followed them, most recently followed first, 100 at a time.
1166
+	 * (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1167
+	 *
1168
+	 * Use the cursor option to access older friends.
1169
+	 * With no user specified, request defaults to the authenticated user's friends.
1170
+	 * It's also possible to request another user's friends list via the id, screen_name or user_id parameter.
1171
+	 *
1172
+	 * @return    array
1173
+	 * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1174
+	 * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1175
+	 * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1176
+	 * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1177
+	 */
1178
+	public function statusesFriends($id = null, $userId = null, $screenName = null, $cursor = null)
1179
+	{
1180
+		// build parameters
1181
+		$parameters = array();
1182
+		if ($id != null) $parameters['id'] = (string)$id;
1183
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1184
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1185
+		if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1186
+
1187
+		// make the call
1188
+		return (array)$this->doCall('statuses/friends.json', $parameters);
1189
+	}
1190
+
1191
+	/**
1192
+	 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they followed the user, 100 at a time. (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1193
+	 * Use the cursor parameter to access earlier followers.
1194
+	 *
1195
+	 * @return    array
1196
+	 * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1197
+	 * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1198
+	 * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1199
+	 * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1200
+	 */
1201
+	public function statusesFollowers($id = null, $userId = null, $screenName = null, $cursor = null)
1202
+	{
1203
+		// build parameters
1204
+		$parameters = array();
1205
+		if ($id != null) $parameters['id'] = (string)$id;
1206
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1207
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1208
+		if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1209
+
1210
+		// make the call
1211
+		return (array)$this->doCall('statuses/followers.json', $parameters);
1212
+	}
1213
+
1214
+
1215
+	// Trends resources
1216
+	/**
1217
+	 * Returns the top ten topics that are currently trending on Twitter.
1218
+	 * The response includes the time of the request, the name of each trend, and the url to the Twitter Search results page for that topic.
1219
+	 *
1220
+	 * @return    array
1221
+	 */
1222
+	public function trends()
1223
+	{
1224
+		return (array)$this->doCall('trends.json');
1225
+	}
1226
+
1227
+	/**
1228
+	 * Returns the current top 10 trending topics on Twitter.
1229
+	 * The response includes the time of the request, the name of each trending topic, and query used on Twitter Search results page for that topic.
1230
+	 *
1231
+	 * @return    array
1232
+	 * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1233
+	 */
1234
+	public function trendsCurrent($exclude = null)
1235
+	{
1236
+		// build parameters
1237
+		$parameters = array();
1238
+		if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1239
+
1240
+		// make the call
1241
+		return (array)$this->doCall('trends/current.json', $parameters);
1242
+	}
1243
+
1244
+	/**
1245
+	 * Returns the top 20 trending topics for each hour in a given day.
1246
+	 *
1247
+	 * @return    array
1248
+	 * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1249
+	 * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1250
+	 */
1251
+	public function trendsDaily($exclude = null, $date = null)
1252
+	{
1253
+		// build parameters
1254
+		$parameters = array();
1255
+		if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1256
+		if ($date != null) $parameters['date'] = (string)$date;
1257
+
1258
+		// make the call
1259
+		return (array)$this->doCall('trends/daily.json', $parameters);
1260
+	}
1261
+
1262
+	/**
1263
+	 * Returns the top 30 trending topics for each day in a given week.
1264
+	 *
1265
+	 * @return    array
1266
+	 * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1267
+	 * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1268
+	 */
1269
+	public function trendsWeekly($exclude = null, $date = null)
1270
+	{
1271
+		// build parameters
1272
+		$parameters = array();
1273
+		if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1274
+		if ($date != null) $parameters['date'] = (string)$date;
1275
+
1276
+		// make the call
1277
+		return (array)$this->doCall('trends/weekly.json', $parameters);
1278
+	}
1279
+
1280
+
1281
+	// List resources
1282
+	/**
1283
+	 * Creates a new list for the authenticated user. Accounts are limited to 20 lists.
1284
+	 *
1285
+	 *
1286
+	 * @param    string $user The user.
1287
+	 * @param    string $name The name of the list you are creating.
1288
+	 * @param null      $mode
1289
+	 * @param null      $description
1290
+	 * @return array
1291
+	 * @throws TwitterException
1292
+	 * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1293
+	 * @internal param $string [optional] $description    The description of the list you are creating.
1294
+	 */
1295
+	public function userListsCreate($user, $name, $mode = null, $description = null)
1296
+	{
1297
+		// possible modes
1298
+		$allowedModes = array('public', 'private');
1299
+
1300
+		// validate
1301
+		if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1302
+
1303
+		// build parameters
1304
+		$parameters['name'] = (string)$name;
1305
+		if ($mode != null) $parameters['mode'] = (string)$mode;
1306
+		if ($description != null) $parameters['description'] = (string)$description;
1307
+
1308
+		// make the call
1309
+		return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST');
1310
+	}
1311
+
1312
+	/**
1313
+	 * List the lists of the specified user. Private lists will be included if the authenticated users is the same as the user who's lists are being returned.
1314
+	 *
1315
+	 * @return    array
1316
+	 * @param    string $user  The user.
1317
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1318
+	 */
1319
+	public function userLists($user, $cursor = null)
1320
+	{
1321
+		$parameters = null;
1322
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1323
+
1324
+		// make the call
1325
+		return (array)$this->doCall((string)$user . '/lists.json', $parameters, true);
1326
+	}
1327
+
1328
+	/**
1329
+	 * Show the specified list. Private lists will only be shown if the authenticated user owns the specified list.
1330
+	 *
1331
+	 * @return    array
1332
+	 * @param    string $user The user.
1333
+	 * @param    string $id   The id of the list.
1334
+	 */
1335
+	public function userListsId($user, $id)
1336
+	{
1337
+		// make the call
1338
+		return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', null, true);
1339
+	}
1340
+
1341
+	/**
1342
+	 * Updates the specified list.
1343
+	 *
1344
+	 *
1345
+	 * @param    string $user The user.
1346
+	 * @param    string $id   The id of the list.
1347
+	 * @param null      $name
1348
+	 * @param null      $mode
1349
+	 * @param null      $description
1350
+	 * @return array
1351
+	 * @throws TwitterException
1352
+	 * @internal param $string [optional] $name            The name of the list you are creating.
1353
+	 * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1354
+	 * @internal param $string [optional] $description    The description of the list you are creating.
1355
+	 */
1356
+	public function userListsIdUpdate($user, $id, $name = null, $mode = null, $description = null)
1357
+	{
1358
+		// possible modes
1359
+		$allowedModes = array('public', 'private');
1360
+
1361
+		// validate
1362
+		if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1363
+
1364
+		// build parameters
1365
+		if ($name != null) $parameters['name'] = (string)$name;
1366
+		if ($mode != null) $parameters['mode'] = (string)$mode;
1367
+		if ($description != null) $parameters['description'] = (string)$description;
1368
+
1369
+		// make the call
1370
+		return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST');
1371
+	}
1372
+
1373
+	/**
1374
+	 * Show tweet timeline for members of the specified list.
1375
+	 *
1376
+	 *
1377
+	 * @param    string $user The user.
1378
+	 * @param    string $id   The id of the list.
1379
+	 * @param null      $sinceId
1380
+	 * @param null      $maxId
1381
+	 * @param null      $count
1382
+	 * @param null      $page
1383
+	 * @return array
1384
+	 * @throws TwitterException
1385
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1386
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1387
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1388
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1389
+	 */
1390
+	public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null)
1391
+	{
1392
+		// validate
1393
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1394
+
1395
+		// build parameters
1396
+		$parameters = array();
1397
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1398
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1399
+		if ($count != null) $parameters['per_page'] = (int)$count;
1400
+		if ($page != null) $parameters['page'] = (int)$page;
1401
+
1402
+		// make the call
1403
+		return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters);
1404
+	}
1405
+
1406
+	/**
1407
+	 * List the lists the specified user has been added to.
1408
+	 *
1409
+	 * @return    array
1410
+	 * @param    string $user  The user.
1411
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1412
+	 */
1413
+	public function userListsMemberships($user, $cursor = null)
1414
+	{
1415
+		$parameters = null;
1416
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1417
+
1418
+		// make the call
1419
+		return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true);
1420
+	}
1421
+
1422
+	/**
1423
+	 * List the lists the specified user follows.
1424
+	 *
1425
+	 * @return    array
1426
+	 * @param    string $user  The user.
1427
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1428
+	 */
1429
+	public function userListsSubscriptions($user, $cursor = null)
1430
+	{
1431
+		$parameters = null;
1432
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1433
+
1434
+		// make the call
1435
+		return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true);
1436
+	}
1437
+
1438
+
1439
+	// List Members resources
1440
+	/**
1441
+	 * Returns the members of the specified list.
1442
+	 *
1443
+	 * @return    array
1444
+	 * @param    string $user  The user.
1445
+	 * @param    string $id    The id of the list.
1446
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1447
+	 */
1448
+	public function userListMembers($user, $id, $cursor = null)
1449
+	{
1450
+		$parameters = null;
1451
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1452
+
1453
+		// make the call
1454
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true);
1455
+	}
1456
+
1457
+	/**
1458
+	 * Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to having 500 members.
1459
+	 *
1460
+	 * @return    array
1461
+	 * @param    string $user   The user.
1462
+	 * @param    string $id     The id of the list.
1463
+	 * @param    string $userId The id or screen name of the user to add as a member of the list.
1464
+	 */
1465
+	public function userListMembersCreate($user, $id, $userId)
1466
+	{
1467
+		// build parameters
1468
+		$parameters['id'] = (string)$userId;
1469
+
1470
+		// make the call
1471
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1472
+	}
1473
+
1474
+	/**
1475
+	 * Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list.
1476
+	 *
1477
+	 * @return    mixed
1478
+	 * @param    string $user   The user.
1479
+	 * @param    string $id     The id of the list.
1480
+	 * @param    string $userId Specfies the ID of the user for whom to return results for.
1481
+	 */
1482
+	public function userListMembersDelete($user, $id, $userId)
1483
+	{
1484
+		// build parameters
1485
+		$parameters['id']      = (string)$userId;
1486
+		$parameters['_method'] = 'DELETE';
1487
+
1488
+		// make the call
1489
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1490
+	}
1491
+
1492
+	/**
1493
+	 * Check if a user is a member of the specified list.
1494
+	 *
1495
+	 *
1496
+	 * @param    string $user   The user.
1497
+	 * @param    string $id     The id of the list.
1498
+	 * @param    string $userId Specfies the ID of the user for whom to return results for.
1499
+	 * @return mixed
1500
+	 * @throws TwitterException
1501
+	 */
1502
+	public function userListMembersId($user, $id, $userId)
1503
+	{
1504
+		try {
1505
+			// make the call
1506
+			return (array)$this->doCall((string)$user . '/' . (string)$id . '/members/' . (string)$userId . '.json', null, true);
1507
+		} // catch exceptions
1508
+		catch (TwitterException $e) {
1509
+			if ($e->getMessage() === 'The specified user is not a member of this list') {
1510
+				return false;
1511
+			} else throw $e;
1512
+		}
1513
+	}
1514
+
1515
+
1516
+	// List Subscribers resources
1517
+	/**
1518
+	 * Returns the subscribers of the specified list.
1519
+	 *
1520
+	 * @return    array
1521
+	 * @param    string $user  The user.
1522
+	 * @param    string $id    The id of the list.
1523
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1524
+	 */
1525
+	public function userListSubscribers($user, $id, $cursor = null)
1526
+	{
1527
+		$parameters = null;
1528
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1529
+
1530
+		// make the call
1531
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true);
1532
+	}
1533
+
1534
+	/**
1535
+	 * Make the authenticated user follow the specified list.
1536
+	 *
1537
+	 * @return    array
1538
+	 * @param    string $user The user.
1539
+	 * @param    string $id   The id of the list.
1540
+	 */
1541
+	public function userListSubscribersCreate($user, $id)
1542
+	{
1543
+		// make the call
1544
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', null, true, 'POST');
1545
+	}
1546
+
1547
+	/**
1548
+	 * Unsubscribes the authenticated user form the specified list.
1549
+	 *
1550
+	 * @return    array
1551
+	 * @param    string $user The user.
1552
+	 * @param    string $id   The id of the list.
1553
+	 */
1554
+	public function userListSubscribersDelete($user, $id)
1555
+	{
1556
+		// build parameters
1557
+		$parameters['_method'] = 'DELETE';
1558
+
1559
+		// make the call
1560
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true, 'POST');
1561
+	}
1562
+
1563
+	/**
1564
+	 * Check if the specified user is a subscriber of the specified list.
1565
+	 *
1566
+	 *
1567
+	 * @param    string $user   The user.
1568
+	 * @param    string $id     The id of the list.
1569
+	 * @param    string $userId Specfies the ID of the user for whom to return results for.
1570
+	 * @return mixed
1571
+	 * @throws TwitterException
1572
+	 */
1573
+	public function userListSubscribersId($user, $id, $userId)
1574
+	{
1575
+		try {
1576
+			// make the call
1577
+			return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers/' . (string)$userId . '.json', null, true);
1578
+		} // catch exceptions
1579
+		catch (TwitterException $e) {
1580
+			if ($e->getMessage() === 'The specified user is not a subscriber of this list') {
1581
+				return false;
1582
+			} else throw $e;
1583
+		}
1584
+
1585
+	}
1586
+
1587
+
1588
+	// Direct Messages resources
1589
+	/**
1590
+	 * Returns a list of the 20 most recent direct messages sent to the authenticating user.
1591
+	 *
1592
+	 *
1593
+	 * @param null $sinceId
1594
+	 * @param null $maxId
1595
+	 * @param null $count
1596
+	 * @param null $page
1597
+	 * @return array
1598
+	 * @throws TwitterException
1599
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1600
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1601
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1602
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1603
+	 */
1604
+	public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null)
1605
+	{
1606
+		// validate
1607
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1608
+
1609
+		// build parameters
1610
+		$parameters = array();
1611
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1612
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1613
+		if ($count != null) $parameters['count'] = (int)$count;
1614
+		if ($page != null) $parameters['page'] = (int)$page;
1615
+
1616
+		// make the call
1617
+		return (array)$this->doCall('direct_messages.json', $parameters, true);
1618
+	}
1619
+
1620
+	/**
1621
+	 * Returns a list of the 20 most recent direct messages sent by the authenticating user.
1622
+	 *
1623
+	 *
1624
+	 * @param null $sinceId
1625
+	 * @param null $maxId
1626
+	 * @param null $count
1627
+	 * @param null $page
1628
+	 * @return array
1629
+	 * @throws TwitterException
1630
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1631
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1632
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1633
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1634
+	 */
1635
+	public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null)
1636
+	{
1637
+		// validate
1638
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1639
+
1640
+		// build parameters
1641
+		$parameters = array();
1642
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1643
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1644
+		if ($count != null) $parameters['count'] = (int)$count;
1645
+		if ($page != null) $parameters['page'] = (int)$page;
1646
+
1647
+		// make the call
1648
+		return (array)$this->doCall('direct_messages/sent.json', $parameters, true);
1649
+	}
1650
+
1651
+	/**
1652
+	 * Sends a new direct message to the specified user from the authenticating user.
1653
+	 * Requires both the user and text parameters. Returns the sent message in the requested format when successful.
1654
+	 *
1655
+	 *
1656
+	 * @param    string $text The text of your direct message. Be sure to URL encode as necessary, and keep it under 140 characters.
1657
+	 * @param null      $id
1658
+	 * @param null      $userId
1659
+	 * @param null      $screenName
1660
+	 * @return array
1661
+	 * @throws TwitterException
1662
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1663
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1664
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1665
+	 */
1666
+	public function directMessagesNew($text, $id = null, $userId = null, $screenName = null)
1667
+	{
1668
+		// validate
1669
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1670
+
1671
+		// build parameters
1672
+		$parameters['text'] = (string)$text;
1673
+		if ($id != null) $parameters['user'] = (string)$id;
1674
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1675
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1676
+
1677
+		// make the call
1678
+		return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST');
1679
+	}
1680
+
1681
+	/**
1682
+	 * Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message.
1683
+	 *
1684
+	 * @return    array
1685
+	 * @param    string $id The ID of the desired direct message.
1686
+	 */
1687
+	public function directMessagesDestroy($id)
1688
+	{
1689
+		// build parameters
1690
+		$parameters['id'] = (string)$id;
1691
+
1692
+		// make the call
1693
+		return (array)$this->doCall('direct_messages/destroy.json', $parameters, true, 'POST');
1694
+	}
1695
+
1696
+
1697
+	// Friendship resources
1698
+	/**
1699
+	 * Allows the authenticating users to follow the user specified in the ID parameter.
1700
+	 * Returns the befriended user in the requested format when successful.
1701
+	 * Returns a string describing the failure condition when unsuccessful.
1702
+	 *
1703
+	 *
1704
+	 * @param null $id
1705
+	 * @param null $userId
1706
+	 * @param null $screenName
1707
+	 * @param bool $follow
1708
+	 * @return mixed
1709
+	 * @throws TwitterException
1710
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1711
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1712
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1713
+	 * @internal param $bool [optional] $follow            Returns public statuses that reference the given set of users.
1714
+	 */
1715
+	public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false)
1716
+	{
1717
+		// validate
1718
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1719
+
1720
+		// build parameters
1721
+		if ($id != null) $parameters['id'] = (string)$id;
1722
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1723
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1724
+		$parameters['follow'] = $follow ? 'true' : 'false';
1725
+
1726
+		// make the call
1727
+		return (array)$this->doCall('friendships/create.json', $parameters, true, 'POST');
1728
+	}
1729
+
1730
+	/**
1731
+	 * Allows the authenticating users to unfollow the user specified in the ID parameter.
1732
+	 * Returns the unfollowed user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
1733
+	 *
1734
+	 *
1735
+	 * @param null $id
1736
+	 * @param null $userId
1737
+	 * @param null $screenName
1738
+	 * @return array
1739
+	 * @throws TwitterException
1740
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1741
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1742
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1743
+	 */
1744
+	public function friendshipsDestroy($id = null, $userId = null, $screenName = null)
1745
+	{
1746
+		// validate
1747
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1748
+
1749
+		// build parameters
1750
+		if ($id != null) $parameters['id'] = (string)$id;
1751
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1752
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1753
+
1754
+		// make the call
1755
+		return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST');
1756
+	}
1757
+
1758
+	/**
1759
+	 * Tests for the existence of friendship between two users. Will return true if user_a follows user_b, otherwise will return false.
1760
+	 *
1761
+	 * @return    bool
1762
+	 * @param    string $userA The ID or screen_name of the subject user.
1763
+	 * @param    string $userB The ID or screen_name of the user to test for following.
1764
+	 */
1765
+	public function friendshipsExists($userA, $userB)
1766
+	{
1767
+		// build parameters
1768
+		$parameters['user_a'] = (string)$userA;
1769
+		$parameters['user_b'] = (string)$userB;
1770
+
1771
+		// make the call
1772
+		return (bool)$this->doCall('friendships/exists.json', $parameters);
1773
+	}
1774
+
1775
+	/**
1776
+	 * Returns detailed information about the relationship between two users.
1777
+	 *
1778
+	 *
1779
+	 * @param null $sourceId
1780
+	 * @param null $sourceScreenName
1781
+	 * @param null $targetId
1782
+	 * @param null $targetScreenName
1783
+	 * @return array
1784
+	 * @throws TwitterException
1785
+	 * @internal param $string [optional] $sourceId                The user_id of the subject user.
1786
+	 * @internal param $string [optional] $sourceScreenName        The screen_name of the subject user.
1787
+	 * @internal param $string [optional] $targetId                The screen_name of the subject user.
1788
+	 * @internal param $string [optional] $targetScreenName        The screen_name of the target user.
1789
+	 */
1790
+	public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
1791
+	{
1792
+		// validate
1793
+		if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.');
1794
+		if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
1795
+
1796
+		// build parameters
1797
+		if ($sourceId != null) $parameters['source_id'] = (string)$sourceId;
1798
+		if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName;
1799
+		if ($targetId != null) $parameters['target_id'] = (string)$targetId;
1800
+		if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName;
1801
+
1802
+		// make the call
1803
+		return (array)$this->doCall('friendships/show.json', $parameters);
1804
+	}
1805
+
1806
+	/**
1807
+	 * Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user.
1808
+	 *
1809
+	 * @return    array
1810
+	 * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1811
+	 */
1812
+	public function friendshipsIncoming($cursor = null)
1813
+	{
1814
+		$parameters = null;
1815
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1816
+
1817
+		// make the call
1818
+		return (array)$this->doCall('friendships/incoming.json', $parameters, true);
1819
+	}
1820
+
1821
+	/**
1822
+	 * Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request.
1823
+	 *
1824
+	 * @return    array
1825
+	 * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1826
+	 */
1827
+	public function friendshipsOutgoing($cursor = null)
1828
+	{
1829
+		$parameters = null;
1830
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1831
+
1832
+		// make the call
1833
+		return (array)$this->doCall('friendships/outgoing.json', $parameters, true);
1834
+	}
1835
+
1836
+
1837
+	// Friends and Followers resources
1838
+	/**
1839
+	 * Returns an array of numeric IDs for every user the specified user is following.
1840
+	 *
1841
+	 *
1842
+	 * @param null $id
1843
+	 * @param null $userId
1844
+	 * @param null $screenName
1845
+	 * @param null $cursor
1846
+	 * @return array
1847
+	 * @throws TwitterException
1848
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1849
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1850
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1851
+	 * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1852
+	 */
1853
+	public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null)
1854
+	{
1855
+		// validate
1856
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1857
+
1858
+		// build parameters
1859
+		if ($id != null) $parameters['id'] = (string)$id;
1860
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1861
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1862
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1863
+
1864
+		// make the call
1865
+		return (array)$this->doCall('friends/ids.json', $parameters);
1866
+	}
1867
+
1868
+	/**
1869
+	 * Returns an array of numeric IDs for every user following the specified user.
1870
+	 *
1871
+	 *
1872
+	 * @param null $id
1873
+	 * @param null $userId
1874
+	 * @param null $screenName
1875
+	 * @param null $cursor
1876
+	 * @return array
1877
+	 * @throws TwitterException
1878
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1879
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1880
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1881
+	 * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1882
+	 */
1883
+	public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null)
1884
+	{
1885
+		// validate
1886
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1887
+
1888
+		// build parameters
1889
+		if ($id != null) $parameters['id'] = (string)$id;
1890
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1891
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1892
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1893
+
1894
+		// make the call
1895
+		return (array)$this->doCall('followers/ids.json', $parameters);
1896
+	}
1897
+
1898
+
1899
+	// Account resources
1900
+	/**
1901
+	 * Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
1902
+	 *
1903
+	 * @return    array
1904
+	 */
1905
+	public function accountVerifyCredentials()
1906
+	{
1907
+		// make the call
1908
+		return (array)$this->doCall('account/verify_credentials.json', null, true);
1909
+	}
1910
+
1911
+	/**
1912
+	 *
1913
+	 * @return    array
1914
+	 */
1915
+	public function accountRateLimitStatus()
1916
+	{
1917
+		// make the call
1918
+		return (array)$this->doCall('account/rate_limit_status.json', null);
1919
+	}
1920
+
1921
+	/**
1922
+	 * Ends the session of the authenticating user, returning a null cookie. Use this method to sign users out of client-facing applications like widgets.
1923
+	 * @return bool
1924
+	 * @throws TwitterException
1925
+	 */
1926
+	public function accountEndSession()
1927
+	{
1928
+		try {
1929
+			// make the call
1930
+			$this->doCall('account/end_session.json', null, true, 'POST');
1931
+		} // catch exceptions
1932
+		catch (TwitterException $e) {
1933
+			if ($e->getMessage() === 'Logged out.') {
1934
+				return true;
1935
+			} else throw $e;
1936
+		}
1937
+	}
1938
+
1939
+	/**
1940
+	 * Sets which device Twitter delivers updates to for the authenticating user. Sending none as the device parameter will disable IM or SMS updates.
1941
+	 *
1942
+	 * @return    array
1943
+	 * @param    string $device Delivery device type to send updates to.
1944
+	 */
1945
+	public function accountUpdateDeliveryDevices($device)
1946
+	{
1947
+		// build parameters
1948
+		$parameters['device'] = (string)$device;
1949
+
1950
+		// make the call
1951
+		return (array)$this->doCall('account/update_delivery_device.json', $parameters, true, 'POST');
1952
+	}
1953
+
1954
+	/**
1955
+	 * Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
1956
+	 * Each parameter's value must be a valid hexidecimal value, and may be either three or six characters (ex: #fff or #ffffff).
1957
+	 *
1958
+	 *
1959
+	 * @param null $profileBackgroundColor
1960
+	 * @param null $profileTextColor
1961
+	 * @param null $profileLinkColor
1962
+	 * @param null $profileSidebarFillColor
1963
+	 * @param null $profileSidebarBorderColor
1964
+	 * @return array
1965
+	 * @throws TwitterException
1966
+	 * @internal param $string [optional] $profileBackgroundColor        Profile background color.
1967
+	 * @internal param $string [optional] $profileTextColor                Profile text color.
1968
+	 * @internal param $string [optional] $profileLinkColor                Profile link color.
1969
+	 * @internal param $string [optional] $profileSidebarFillColor        Profile sidebar's background color.
1970
+	 * @internal param $string [optional] $profileSidebarBorderColor        Profile sidebar's border color.
1971
+	 */
1972
+	public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null)
1973
+	{
1974
+		// validate
1975
+		if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == ''
1976
+			&& $profileSidebarBorderColor == ''
1977
+		) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
1978
+
1979
+		// build parameters
1980
+		if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor;
1981
+		if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor;
1982
+		if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor;
1983
+		if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
1984
+		if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
1985
+
1986
+		// make the call
1987
+		return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
1988
+	}
1989
+
1990
+	/**
1991
+	 * Updates the authenticating user's profile image.
1992
+	 *
1993
+	 *
1994
+	 * @param    string $image The path to the avatar image for the profile. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.
1995
+	 * @return array
1996
+	 * @throws TwitterException
1997
+	 */
1998
+	public function accountUpdateProfileImage($image)
1999
+	{
2000
+		throw new TwitterException('Not implemented');
2001
+
2002
+		// validate
2003
+		if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2004
+
2005
+		// make the call
2006
+		return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
2007
+	}
2008
+
2009
+	/**
2010
+	 * Updates the authenticating user's profile background image.
2011
+	 *
2012
+	 *
2013
+	 * @param    string $image The path to the background image for the profile. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forceably scaled down.
2014
+	 * @param    bool   $tile  Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
2015
+	 * @return array
2016
+	 * @throws TwitterException
2017
+	 */
2018
+	public function accountUpdateProfileBackgroundImage($image, $tile = false)
2019
+	{
2020
+		throw new TwitterException('Not implemented');
2021
+
2022
+		// validate
2023
+		if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2024
+
2025
+		// build parameters
2026
+		if ($tile) $parameters['tile'] = 'true';
2027
+
2028
+		// make the call
2029
+		return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
2030
+	}
2031
+
2032
+	/**
2033
+	 * Sets values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated.
2034
+	 *
2035
+	 * @return    array
2036
+	 * @param    string [optional] $name            Full name associated with the profile. Maximum of 20 characters.
2037
+	 * @param    string [optional] $url            URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
2038
+	 * @param    string [optional] $location        The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
2039
+	 * @param    string [optional] $description    A description of the user owning the account. Maximum of 160 characters.
2040
+	 */
2041
+	public function accountUpdateProfile($name = null, $url = null, $location = null, $description = null)
2042
+	{
2043
+		// build parameters
2044
+		$parameters = null;
2045
+		if ($name != null) $parameters['name'] = (string)$name;
2046
+		if ($url != null) $parameters['url'] = (string)$url;
2047
+		if ($location != null) $parameters['location'] = (string)$location;
2048
+		if ($description != null) $parameters['description'] = (string)$description;
2049
+
2050
+		// make the call
2051
+		return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST');
2052
+	}
2053
+
2054
+
2055
+	// Favorites resources
2056
+	/**
2057
+	 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
2058
+	 *
2059
+	 * @return    array
2060
+	 * @param    string [optional] $id    Specifies the ID or screen name of the user for whom to return results for.
2061
+	 * @param    int    [optional] $page        Specifies the page of results to retrieve.
2062
+	 */
2063
+	public function favorites($id = null, $page = null)
2064
+	{
2065
+		// build parameters
2066
+		$parameters = null;
2067
+		if ($id != null) $parameters['id'] = (string)$id;
2068
+		if ($page != null) $parameters['page'] = (int)$page;
2069
+
2070
+		// make the call
2071
+		return (array)$this->doCall('favorites.json', $parameters, true);
2072
+	}
2073
+
2074
+	/**
2075
+	 * Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.
2076
+	 *
2077
+	 * @return    array
2078
+	 * @param    string $id The numerical ID of the desired status.
2079
+	 */
2080
+	public function favoritesCreate($id)
2081
+	{
2082
+		// make the call
2083
+		return (array)$this->doCall('favorites/create/' . $id . '.json', null, true, 'POST');
2084
+	}
2085
+
2086
+	/**
2087
+	 * Un-favorites the status specified in the ID parameter as the authenticating user. Returns the un-favorited status in the requested format when successful.
2088
+	 *
2089
+	 * @return    array
2090
+	 * @param    string $id The numerical ID of the desired status.
2091
+	 */
2092
+	public function favoritesDestroy($id)
2093
+	{
2094
+		// make the call
2095
+		return (array)$this->doCall('favorites/destroy/' . $id . '.json', null, true, 'POST');
2096
+	}
2097
+
2098
+
2099
+	// Notification resources
2100
+	/**
2101
+	 * Enables device notifications for updates from the specified user. Returns the specified user when successful.
2102
+	 *
2103
+	 *
2104
+	 * @param null $id
2105
+	 * @param null $userId
2106
+	 * @param null $screenName
2107
+	 * @return array
2108
+	 * @throws TwitterException
2109
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2110
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2111
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2112
+	 */
2113
+	public function notificationsFollow($id = null, $userId = null, $screenName = null)
2114
+	{
2115
+		// validate
2116
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2117
+
2118
+		// build parameters
2119
+		if ($id != null) $parameters['id'] = (string)$id;
2120
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2121
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2122
+
2123
+		// make the call
2124
+		return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST');
2125
+	}
2126
+
2127
+	/**
2128
+	 * Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
2129
+	 *
2130
+	 *
2131
+	 * @param null $id
2132
+	 * @param null $userId
2133
+	 * @param null $screenName
2134
+	 * @return array
2135
+	 * @throws TwitterException
2136
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2137
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2138
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2139
+	 */
2140
+	public function notificationsLeave($id = null, $userId = null, $screenName = null)
2141
+	{
2142
+		// validate
2143
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2144
+
2145
+		// build parameters
2146
+		if ($id != null) $parameters['id'] = (string)$id;
2147
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2148
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2149
+
2150
+		// make the call
2151
+		return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST');
2152
+	}
2153
+
2154
+
2155
+	// Block resources
2156
+	/**
2157
+	 * Blocks the user specified in the ID parameter as the authenticating user. Destroys a friendship to the blocked user if it exists. Returns the blocked user in the requested format when successful.
2158
+	 *
2159
+	 *
2160
+	 * @param null $id
2161
+	 * @param null $userId
2162
+	 * @param null $screenName
2163
+	 * @return array
2164
+	 * @throws TwitterException
2165
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2166
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2167
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2168
+	 */
2169
+	public function blocksCreate($id = null, $userId = null, $screenName = null)
2170
+	{
2171
+		// validate
2172
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2173
+
2174
+		// build parameters
2175
+		if ($id != null) $parameters['id'] = (string)$id;
2176
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2177
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2178
+
2179
+		// make the call
2180
+		return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST');
2181
+	}
2182
+
2183
+	/**
2184
+	 * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2185
+	 *
2186
+	 *
2187
+	 * @param null $id
2188
+	 * @param null $userId
2189
+	 * @param null $screenName
2190
+	 * @return array
2191
+	 * @throws TwitterException
2192
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2193
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2194
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2195
+	 */
2196
+	public function blocksDestroy($id = null, $userId = null, $screenName = null)
2197
+	{
2198
+		// validate
2199
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2200
+
2201
+		// build parameters
2202
+		if ($id != null) $parameters['id'] = (string)$id;
2203
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2204
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2205
+
2206
+		// make the call
2207
+		return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST');
2208
+	}
2209
+
2210
+	/**
2211
+	 * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2212
+	 *
2213
+	 *
2214
+	 * @param null $id
2215
+	 * @param null $userId
2216
+	 * @param null $screenName
2217
+	 * @return mixed
2218
+	 * @throws TwitterException
2219
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2220
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2221
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2222
+	 */
2223
+	public function blocksExists($id = null, $userId = null, $screenName = null)
2224
+	{
2225
+		// validate
2226
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2227
+
2228
+		// build parameters
2229
+		if ($id != null) $parameters['id'] = (string)$id;
2230
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2231
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2232
+
2233
+		try {
2234
+			// make the call
2235
+			return (array)$this->doCall('blocks/exists.json', $parameters, true);
2236
+		} // catch exceptions
2237
+		catch (TwitterException $e) {
2238
+			if ($e->getMessage() === 'You are not blocking this user.') {
2239
+				return false;
2240
+			} else throw $e;
2241
+		}
2242
+	}
2243
+
2244
+	/**
2245
+	 * Returns an array of user objects that the authenticating user is blocking.
2246
+	 *
2247
+	 * @return    array
2248
+	 * @param    int [optional] $page        Specifies the page of results to retrieve. Note: there are pagination limits. See the FAQ for details.
2249
+	 */
2250
+	public function blocksBlocking($page = null)
2251
+	{
2252
+		// build parameters
2253
+		$parameters = null;
2254
+		if ($page != null) $parameters['page'] = (int)$page;
2255
+
2256
+		// make the call
2257
+		return (array)$this->doCall('blocks/blocking.json', $parameters, true);
2258
+	}
2259
+
2260
+	/**
2261
+	 * Returns an array of numeric user ids the authenticating user is blocking.
2262
+	 *
2263
+	 * @return    array
2264
+	 */
2265
+	public function blocksBlockingIds()
2266
+	{
2267
+		// make the call
2268
+		return (array)$this->doCall('blocks/blocking/ids.json', null, true);
2269
+	}
2270
+
2271
+
2272
+	// Spam Reporting resources
2273
+	/**
2274
+	 * The user specified in the id is blocked by the authenticated user and reported as a spammer.
2275
+	 *
2276
+	 *
2277
+	 * @param null $id
2278
+	 * @param null $userId
2279
+	 * @param null $screenName
2280
+	 * @return array
2281
+	 * @throws TwitterException
2282
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2283
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2284
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2285
+	 */
2286
+	public function reportSpam($id = null, $userId = null, $screenName = null)
2287
+	{
2288
+		// validate
2289
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2290
+
2291
+		// build parameters
2292
+		if ($id != null) $parameters['id'] = (string)$id;
2293
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2294
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2295
+
2296
+		// make the call
2297
+		return (array)$this->doCall('report_spam.json', $parameters, true, 'POST');
2298
+	}
2299
+
2300
+
2301
+	// Saved Searches resources
2302
+	/**
2303
+	 * Returns the authenticated user's saved search queries.
2304
+	 *
2305
+	 * @return    array
2306
+	 */
2307
+	public function savedSearches()
2308
+	{
2309
+		// make the call
2310
+		return (array)$this->doCall('saved_searches.json', null, true);
2311
+	}
2312
+
2313
+	/**
2314
+	 * Retrieve the data for a saved search owned by the authenticating user specified by the given id.
2315
+	 *
2316
+	 * @return    array
2317
+	 * @param    string $id The ID of the desired saved search.
2318
+	 */
2319
+	public function savedSearchesShow($id)
2320
+	{
2321
+		// build parameters
2322
+		$parameters['id'] = (string)$id;
2323
+
2324
+		// make the call
2325
+		return (array)$this->doCall('saved_searches/show.json', $parameters, true);
2326
+	}
2327
+
2328
+	/**
2329
+	 * Creates a saved search for the authenticated user.
2330
+	 *
2331
+	 * @return    array
2332
+	 * @param    string $query The query of the search the user would like to save.
2333
+	 */
2334
+	public function savedSearchesCreate($query)
2335
+	{
2336
+		// build parameters
2337
+		$parameters['query'] = (string)$query;
2338
+
2339
+		// make the call
2340
+		return (array)$this->doCall('saved_searches/create.json', $parameters, true, 'POST');
2341
+	}
2342
+
2343
+	/**
2344
+	 * Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
2345
+	 * REMARK: This method seems not to work    @later
2346
+	 *
2347
+	 * @return    array
2348
+	 * @param    string $id The ID of the desired saved search.
2349
+	 */
2350
+	public function savedSearchesDestroy($id)
2351
+	{
2352
+		return (array)$this->doCall('saved_searches/destroy/' . (string)$id . '.json', null, true, 'POST');
2353
+	}
2354
+
2355
+
2356
+	// OAuth resources
2357
+	/**
2358
+	 * Allows a Consumer application to obtain an OAuth Request Token to request user authorization.
2359
+	 * This method fulfills Secion 6.1 of the OAuth 1.0 authentication flow.
2360
+	 *
2361
+	 *
2362
+	 * @param    string $callbackURL
2363
+	 * @return array An array containg the token and the secret
2364
+	 * @throws TwitterException
2365
+	 */
2366
+	public function oAuthRequestToken($callbackURL = null)
2367
+	{
2368
+		// init var
2369
+		$parameters = array();
2370
+
2371
+		// set callback
2372
+		if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL;
2373
+
2374
+		// make the call
2375
+		$response = $this->doOAuthCall('request_token', $parameters);
2376
+
2377
+		// validate
2378
+		if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response)));
2379
+
2380
+		// set some properties
2381
+		if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2382
+		if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2383
+
2384
+		// return
2385
+		return $response;
2386
+	}
2387
+
2388
+	/**
2389
+	 * Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token.
2390
+	 * This method fulfills Secion 6.3 of the OAuth 1.0 authentication flow.
2391
+	 *
2392
+	 * @return    array
2393
+	 * @param    string $token
2394
+	 * @param    string $verifier
2395
+	 */
2396
+	public function oAuthAccessToken($token, $verifier)
2397
+	{
2398
+		// init var
2399
+		$parameters                   = array();
2400
+		$parameters['oauth_token']    = (string)$token;
2401
+		$parameters['oauth_verifier'] = (string)$verifier;
2402
+
2403
+		// make the call
2404
+		$response = $this->doOAuthCall('access_token', $parameters);
2405
+
2406
+		// set some properties
2407
+		if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2408
+		if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2409
+
2410
+		// return
2411
+		return $response;
2412
+	}
2413
+
2414
+	/**
2415
+	 * Will redirect to the page to authorize the applicatione
2416
+	 *
2417
+	 * @return    void
2418
+	 */
2419
+	public function oAuthAuthorize()
2420
+	{
2421
+		header('Location: ' . self::SECURE_API_URL . '/oauth/authorize?oauth_token=' . $this->oAuthToken);
2422
+	}
2423
+
2424
+	/**
2425
+	 * Allows a Consumer application to use an OAuth request_token to request user authorization. This method is a replacement fulfills Secion 6.2 of the OAuth 1.0 authentication flow for applications using the Sign in with Twitter authentication flow. The method will use the currently logged in user as the account to for access authorization unless the force_login parameter is set to true
2426
+	 * REMARK: This method seems not to work    @later
2427
+	 *
2428
+	 * @return    void
2429
+	 */
2430
+	public function oAuthAuthenticate()
2431
+	{
2432
+		// make the call
2433
+		return $this->doOAuthCall('authenticate');
2434
+	}
2435
+
2436
+
2437
+	// Local Trends resources
2438
+	/**
2439
+	 * Returns the locations that Twitter has trending topic information for.
2440
+	 * The response is an array of "locations" that encode the location's WOEID (a Yahoo! Where On Earth ID) and some other human-readable information such as a canonical name and country the location belongs in.
2441
+	 * The WOEID that is returned in the location object is to be used when querying for a specific trend.
2442
+	 *
2443
+	 * @return    array
2444
+	 * @param    float [optional] $lat    If passed in conjunction with long, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2445
+	 * @param    float [optional] $long    If passed in conjunction with lat, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2446
+	 */
2447
+	public function trendsAvailable($lat = null, $long = null)
2448
+	{
2449
+		// build parameters
2450
+		$parameters = null;
2451
+		if ($lat != null) $parameters['lat_for_trends'] = (float)$lat;
2452
+		if ($long != null) $parameters['long_for_trends'] = (float)$long;
2453
+
2454
+		// make the call
2455
+		return (array)$this->doCall('trends/available.json', $parameters);
2456
+	}
2457
+
2458
+	/**
2459
+	 * Returns the top 10 trending topics for a specific location Twitter has trending topic information for.
2460
+	 * The response is an array of "trend" objects that encode the name of the trending topic, the query parameter that can be used to search for the topic on Search, and the direct URL that can be issued against Search.
2461
+	 * This information is cached for five minutes, and therefore users are discouraged from querying these endpoints faster than once every five minutes. Global trends information is also available from this API by using a WOEID of 1.
2462
+	 * REMARK: This method seems not to work    @later
2463
+	 *
2464
+	 * @return    array
2465
+	 * @param    string $woeid The WOEID of the location to be querying for.
2466
+	 */
2467
+	public function trendsLocation($woeid)
2468
+	{
2469
+		// make the call
2470
+		return (array)$this->doCall('trends/location/' . (string)$woeid . '.json');
2471
+	}
2472
+
2473
+
2474
+	// Geo resources
2475
+	/**
2476
+	 * Search for places (cities and neighborhoods) that can be attached to a statuses/update. Given a latitude and a longitude, return a list of all the valid places that can be used as a place_id when updating a status.
2477
+	 * Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location up with a call to statuses/update.
2478
+	 * There are multiple granularities of places that can be returned -- "neighborhoods", "cities", etc. At this time, only United States data is available through this method.
2479
+	 * This API call is meant to be an informative call and will deliver generalized results about geography.
2480
+	 *
2481
+	 * @return    array
2482
+	 * @param    float $lat   The location's latitude that this tweet refers to.
2483
+	 * @param    float $long  The location's longitude that this tweet refers to.
2484
+	 * @param          string [optional] $accuracy        A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
2485
+	 * @param          string [optional] $granularity    The minimal granularity of data to return. If this is not passed in, then neighborhood is assumed. city can also be passed.
2486
+	 * @param          int    [optional] $maxResults        A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
2487
+	 */
2488
+	public function geoReverseGeoCode($lat, $long, $accuracy = null, $granularity = null, $maxResults = null)
2489
+	{
2490
+		// build parameters
2491
+		$parameters['lat']  = (float)$lat;
2492
+		$parameters['long'] = (float)$long;
2493
+		if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy;
2494
+		if ($granularity != null) $parameters['granularity'] = (string)$granularity;
2495
+		if ($maxResults != null) $parameters['max_results'] = (int)$maxResults;
2496
+
2497
+		// make the call
2498
+		return (array)$this->doCall('geo/reverse_geocode.json', $parameters);
2499
+	}
2500
+
2501
+	/**
2502
+	 * Find out more details of a place that was returned from the geo/reverse_geocode method.
2503
+	 *
2504
+	 * @return    array
2505
+	 * @param    string $id
2506
+	 * @param           string [optional] $placeId    A place in the world. These IDs can be retrieved from geo/reverse_geocode.
2507
+	 */
2508
+	public function geoId($id, $placeId = null)
2509
+	{
2510
+		// build parameters
2511
+		$parameters = null;
2512
+		if ($placeId != null) $parameters['place_id'] = (string)$placeId;
2513
+
2514
+		// make the call
2515
+		return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters);
2516
+	}
2517
+
2518
+
2519
+	// Help resources
2520
+	/**
2521
+	 * Test
2522
+	 * REMARK: this methods seems not to work, so don't rely on it
2523
+	 *
2524
+	 * @return    bool
2525
+	 */
2526
+	public function helpTest()
2527
+	{
2528
+		// make the call
2529
+		return ($this->doCall('help/test', null, null, 'GET', null, false) == 'ok');
2530
+	}
2531 2531
 }
2532 2532
 
2533 2533
 /**
Please login to merge, or discard this patch.
plugins/actions/twitter/plugins.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -29,111 +29,111 @@
 block discarded – undo
29 29
  */
30 30
 class referencesTwitterAction extends references_action
31 31
 {
32
-    public function registerEvents()
33
-    {
34
-        /**
35
-         * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
36
-         *
37
-         * Indice    Signification
38
-         * ----------------------
39
-         *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
40
-         *    1        Priorité du plugin (de 1 à 5)
41
-         *    2        Script Php à inclure
42
-         *    3        Classe à instancier
43
-         *    4        Méthode à appeler
44
-         */
45
-        $events   = array();
46
-        $events[] = array(
47
-            references_plugins::EVENT_ON_REFERENCE_CREATE,
48
-            references_plugins::EVENT_PRIORITY_1,
49
-            basename(__FILE__),
50
-            __CLASS__,
51
-            'fireNewReference'
52
-        );
53
-        $events[] = array(
54
-            references_plugins::EVENT_ON_CATEGORY_CREATE,
55
-            references_plugins::EVENT_PRIORITY_1,
56
-            basename(__FILE__),
57
-            __CLASS__,
58
-            'fireNewCategory'
59
-        );
60
-        return $events;
61
-    }
32
+	public function registerEvents()
33
+	{
34
+		/**
35
+		 * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
36
+		 *
37
+		 * Indice    Signification
38
+		 * ----------------------
39
+		 *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
40
+		 *    1        Priorité du plugin (de 1 à 5)
41
+		 *    2        Script Php à inclure
42
+		 *    3        Classe à instancier
43
+		 *    4        Méthode à appeler
44
+		 */
45
+		$events   = array();
46
+		$events[] = array(
47
+			references_plugins::EVENT_ON_REFERENCE_CREATE,
48
+			references_plugins::EVENT_PRIORITY_1,
49
+			basename(__FILE__),
50
+			__CLASS__,
51
+			'fireNewReference'
52
+		);
53
+		$events[] = array(
54
+			references_plugins::EVENT_ON_CATEGORY_CREATE,
55
+			references_plugins::EVENT_PRIORITY_1,
56
+			basename(__FILE__),
57
+			__CLASS__,
58
+			'fireNewCategory'
59
+		);
60
+		return $events;
61
+	}
62 62
 
63
-    /**
64
-     * Méthode générique chargée d'envoyer un texte sur un compte twitter avec une url
65
-     *
66
-     * @param string $textToSend Le texte à envoyer
67
-     * @param string $mask       Le masque à utiliser
68
-     * @param string $elementUrl L'url de l'élément concerné
69
-     * @return string                Le texte qui a été envoyé à twitter
70
-     */
71
-    private function sendTextToTwitter($textToSend, $mask, $elementUrl)
72
-    {
73
-        if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
74
-            define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
75
-        }
76
-        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
77
-        //require_once REFERENCES_TWITTER_PLUGIN_PATH.'twitter.php';
78
-        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'Twitter.class.php';
79
-        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'bitly.class.php';
80
-        if (REFERENCES_BITLY_LOGIN == '') {
81
-            return '';
82
-        }
83
-        $sentText    = '';
84
-        $bitly       = new Bitly(REFERENCES_BITLY_LOGIN, REFERENCES_BITLY_API_KEY);
85
-        $shortUrl    = $bitly->shortenSingle($elementUrl);
86
-        $searches    = array('[itemname]', '[url]');
87
-        $replaces    = array($textToSend, $shortUrl);
88
-        $sentText    = str_replace($searches, $replaces, $mask);
89
-        $totalLength = strlen($sentText);
90
-        if ($totalLength > REFERENCES_TWITTER_TWIT_MAX_LENGTH) {
91
-            $tooLongOf = $totalLength - REFERENCES_TWITTER_TWIT_MAX_LENGTH;
92
-            $searches  = array('[itemname]', '[url]');
93
-            $replaces  = array(substr($textToSend, 0, strlen($textToSend) - $tooLongOf), $shortUrl);
94
-            $sentText  = str_replace($searches, $replaces, $mask);
95
-        }
96
-        if (trim($sentText) != '') {
97
-            //			$twitter = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD);
98
-            //			$twitter->setUserAgent('references');
99
-            //			$twitter->updateStatus($sentText);
100
-            $tweet = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD);
101
-            $tweet->update($sentText);
102
-        }
103
-        return $sentText;
104
-    }
63
+	/**
64
+	 * Méthode générique chargée d'envoyer un texte sur un compte twitter avec une url
65
+	 *
66
+	 * @param string $textToSend Le texte à envoyer
67
+	 * @param string $mask       Le masque à utiliser
68
+	 * @param string $elementUrl L'url de l'élément concerné
69
+	 * @return string                Le texte qui a été envoyé à twitter
70
+	 */
71
+	private function sendTextToTwitter($textToSend, $mask, $elementUrl)
72
+	{
73
+		if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
74
+			define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
75
+		}
76
+		require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
77
+		//require_once REFERENCES_TWITTER_PLUGIN_PATH.'twitter.php';
78
+		require_once REFERENCES_TWITTER_PLUGIN_PATH . 'Twitter.class.php';
79
+		require_once REFERENCES_TWITTER_PLUGIN_PATH . 'bitly.class.php';
80
+		if (REFERENCES_BITLY_LOGIN == '') {
81
+			return '';
82
+		}
83
+		$sentText    = '';
84
+		$bitly       = new Bitly(REFERENCES_BITLY_LOGIN, REFERENCES_BITLY_API_KEY);
85
+		$shortUrl    = $bitly->shortenSingle($elementUrl);
86
+		$searches    = array('[itemname]', '[url]');
87
+		$replaces    = array($textToSend, $shortUrl);
88
+		$sentText    = str_replace($searches, $replaces, $mask);
89
+		$totalLength = strlen($sentText);
90
+		if ($totalLength > REFERENCES_TWITTER_TWIT_MAX_LENGTH) {
91
+			$tooLongOf = $totalLength - REFERENCES_TWITTER_TWIT_MAX_LENGTH;
92
+			$searches  = array('[itemname]', '[url]');
93
+			$replaces  = array(substr($textToSend, 0, strlen($textToSend) - $tooLongOf), $shortUrl);
94
+			$sentText  = str_replace($searches, $replaces, $mask);
95
+		}
96
+		if (trim($sentText) != '') {
97
+			//			$twitter = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD);
98
+			//			$twitter->setUserAgent('references');
99
+			//			$twitter->updateStatus($sentText);
100
+			$tweet = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD);
101
+			$tweet->update($sentText);
102
+		}
103
+		return $sentText;
104
+	}
105 105
 
106
-    /**
107
-     * Méthode appelée pour indiquer qu'une nouvelle référence a été publié
108
-     *
109
-     * @param object $parameters La référence qui vient d'être publiée
110
-     * @return void
111
-     */
112
-    public function fireNewReference($parameters)
113
-    {
114
-        if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
115
-            define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
116
-        }
117
-        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
118
-        $reference = $parameters['reference'];
119
-        $this->sendTextToTwitter(utf8_encode($reference->getVar('article_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_REFERENCE_INTRO), $reference->getUrl());
120
-    }
106
+	/**
107
+	 * Méthode appelée pour indiquer qu'une nouvelle référence a été publié
108
+	 *
109
+	 * @param object $parameters La référence qui vient d'être publiée
110
+	 * @return void
111
+	 */
112
+	public function fireNewReference($parameters)
113
+	{
114
+		if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
115
+			define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
116
+		}
117
+		require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
118
+		$reference = $parameters['reference'];
119
+		$this->sendTextToTwitter(utf8_encode($reference->getVar('article_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_REFERENCE_INTRO), $reference->getUrl());
120
+	}
121 121
 
122
-    /**
123
-     * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée
124
-     *
125
-     * @param object $parameters La catégorie qui vient d'être publiée
126
-     * @return void
127
-     */
128
-    public function fireNewCategory($parameters)
129
-    {
130
-        if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
131
-            define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
132
-        }
133
-        require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
134
-        if (trim(REFERENCES_TWITTER_NEW_CATEGORY_INTRO) != '') {
135
-            $category = $parameters['category'];
136
-            $this->sendTextToTwitter(utf8_encode($category->getVar('category_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_CATEGORY_INTRO), $category->getUrl());
137
-        }
138
-    }
122
+	/**
123
+	 * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée
124
+	 *
125
+	 * @param object $parameters La catégorie qui vient d'être publiée
126
+	 * @return void
127
+	 */
128
+	public function fireNewCategory($parameters)
129
+	{
130
+		if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) {
131
+			define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR);
132
+		}
133
+		require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php';
134
+		if (trim(REFERENCES_TWITTER_NEW_CATEGORY_INTRO) != '') {
135
+			$category = $parameters['category'];
136
+			$this->sendTextToTwitter(utf8_encode($category->getVar('category_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_CATEGORY_INTRO), $category->getUrl());
137
+		}
138
+	}
139 139
 }
Please login to merge, or discard this patch.
plugins/actions/newreference/plugins.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -25,49 +25,49 @@
 block discarded – undo
25 25
  */
26 26
 class referencesNewreferenceAction extends references_action
27 27
 {
28
-    public function registerEvents()
29
-    {
30
-        /**
31
-         * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
32
-         *
33
-         * Indice   Signification
34
-         * ----------------------
35
-         *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
36
-         *    1        Priorité du plugin (de 1 à 5)
37
-         *    2        Script Php à inclure
38
-         *    3        Classe à instancier
39
-         *    4        Méthode à appeler
40
-         */
41
-        $events   = array();
42
-        $events[] = array(
43
-            references_plugins::EVENT_ON_REFERENCE_CREATE,
44
-            references_plugins::EVENT_PRIORITY_1,
45
-            basename(__FILE__),
46
-            __CLASS__,
47
-            'fireNewReference'
48
-        );
28
+	public function registerEvents()
29
+	{
30
+		/**
31
+		 * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
32
+		 *
33
+		 * Indice   Signification
34
+		 * ----------------------
35
+		 *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
36
+		 *    1        Priorité du plugin (de 1 à 5)
37
+		 *    2        Script Php à inclure
38
+		 *    3        Classe à instancier
39
+		 *    4        Méthode à appeler
40
+		 */
41
+		$events   = array();
42
+		$events[] = array(
43
+			references_plugins::EVENT_ON_REFERENCE_CREATE,
44
+			references_plugins::EVENT_PRIORITY_1,
45
+			basename(__FILE__),
46
+			__CLASS__,
47
+			'fireNewReference'
48
+		);
49 49
 
50
-        return $events;
51
-    }
50
+		return $events;
51
+	}
52 52
 
53
-    /**
54
-     * Méthode appelée pour indiquer qu'une nouvelle référence a été créée
55
-     *
56
-     * @param object $parameters La référence qui vient d'être publiée
57
-     * @return void
58
-     */
59
-    public function fireNewReference($parameters)
60
-    {
61
-        $article              = $parameters['reference'];
62
-        $notification_handler = xoops_getHandler('notification');
63
-        $articleForTemplate   = array();
64
-        $originalArticle      = $article->toArray('n');
53
+	/**
54
+	 * Méthode appelée pour indiquer qu'une nouvelle référence a été créée
55
+	 *
56
+	 * @param object $parameters La référence qui vient d'être publiée
57
+	 * @return void
58
+	 */
59
+	public function fireNewReference($parameters)
60
+	{
61
+		$article              = $parameters['reference'];
62
+		$notification_handler = xoops_getHandler('notification');
63
+		$articleForTemplate   = array();
64
+		$originalArticle      = $article->toArray('n');
65 65
 
66
-        foreach ($originalArticle as $key => $value) {
67
-            @$articleForTemplate[strtoupper($key)] = strip_tags($value);
68
-        }
69
-        $articleForTemplate['REFERENCES_URL']     = $article->getUrl();
70
-        $articleForTemplate['ARTICLE_SHORT_TEXT'] = references_utils::truncate_tagsafe($article->getVar('article_text'), REFERENCES_SHORTEN_TEXT);
71
-        $notification_handler->triggerEvent('global', 0, 'new_article', $articleForTemplate);
72
-    }
66
+		foreach ($originalArticle as $key => $value) {
67
+			@$articleForTemplate[strtoupper($key)] = strip_tags($value);
68
+		}
69
+		$articleForTemplate['REFERENCES_URL']     = $article->getUrl();
70
+		$articleForTemplate['ARTICLE_SHORT_TEXT'] = references_utils::truncate_tagsafe($article->getVar('article_text'), REFERENCES_SHORTEN_TEXT);
71
+		$notification_handler->triggerEvent('global', 0, 'new_article', $articleForTemplate);
72
+	}
73 73
 }
Please login to merge, or discard this patch.
plugins/models/references_action.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
  * Every action plugin must extend this class
24 24
  */
25 25
 if (!defined('XOOPS_ROOT_PATH')) {
26
-    die('XOOPS root path not defined');
26
+	die('XOOPS root path not defined');
27 27
 }
28 28
 
29 29
 abstract class references_action
30 30
 {
31
-    /**
32
-     * Retourne la liste des évènements traités par le plugin
33
-     * @return array
34
-     */
35
-    abstract public function registerEvents();
31
+	/**
32
+	 * Retourne la liste des évènements traités par le plugin
33
+	 * @return array
34
+	 */
35
+	abstract public function registerEvents();
36 36
 }
Please login to merge, or discard this patch.
plugins/models/references_filter.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
  * Every filter plugin must extend this class
24 24
  */
25 25
 if (!defined('XOOPS_ROOT_PATH')) {
26
-    die('XOOPS root path not defined');
26
+	die('XOOPS root path not defined');
27 27
 }
28 28
 
29 29
 abstract class references_filter
30 30
 {
31
-    /**
32
-     * Retourne la liste des évènements traités par le plugin
33
-     * @return array
34
-     */
35
-    abstract public function registerEvents();
31
+	/**
32
+	 * Retourne la liste des évènements traités par le plugin
33
+	 * @return array
34
+	 */
35
+	abstract public function registerEvents();
36 36
 }
Please login to merge, or discard this patch.
extra/modules/sitemap/plugins/references.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@
 block discarded – undo
20 20
  */
21 21
 function b_sitemap_references()
22 22
 {
23
-    require XOOPS_ROOT_PATH . '/modules/references/include/common.php';
24
-    $sitemap    = array();
25
-    $categories = $h_references_categories->getCategories();
26
-    $i          = 0;
27
-    foreach ($categories as $category) {
28
-        $sitemap['parent'][$i]['id']    = $category->getVar('category_id');
29
-        $sitemap['parent'][$i]['title'] = $category->getVar('category_title');
30
-        $sitemap['parent'][$i]['url']   = $category->getUrl(true);
31
-        ++$i;
32
-    }
23
+	require XOOPS_ROOT_PATH . '/modules/references/include/common.php';
24
+	$sitemap    = array();
25
+	$categories = $h_references_categories->getCategories();
26
+	$i          = 0;
27
+	foreach ($categories as $category) {
28
+		$sitemap['parent'][$i]['id']    = $category->getVar('category_id');
29
+		$sitemap['parent'][$i]['title'] = $category->getVar('category_title');
30
+		$sitemap['parent'][$i]['url']   = $category->getUrl(true);
31
+		++$i;
32
+	}
33 33
 
34
-    return $sitemap;
34
+	return $sitemap;
35 35
 }
Please login to merge, or discard this patch.
extra/modules/rss/plugins/rssfit.references.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,53 +19,53 @@
 block discarded – undo
19 19
  * ****************************************************************************
20 20
  */
21 21
 if (!defined('RSSFIT_ROOT_PATH')) {
22
-    exit();
22
+	exit();
23 23
 }
24 24
 
25 25
 class RssfitReferences
26 26
 {
27
-    public $dirname = 'references';
28
-    public $modname;
29
-    public $grab;
27
+	public $dirname = 'references';
28
+	public $modname;
29
+	public $grab;
30 30
 
31
-    public function __construct()
32
-    {
33
-    }
31
+	public function __construct()
32
+	{
33
+	}
34 34
 
35
-    public function loadModule()
36
-    {
37
-        $mod =& $GLOBALS['module_handler']->getByDirname($this->dirname);
38
-        if (!$mod || !$mod->getVar('isactive')) {
39
-            return false;
40
-        }
41
-        $this->modname = $mod->getVar('name');
35
+	public function loadModule()
36
+	{
37
+		$mod =& $GLOBALS['module_handler']->getByDirname($this->dirname);
38
+		if (!$mod || !$mod->getVar('isactive')) {
39
+			return false;
40
+		}
41
+		$this->modname = $mod->getVar('name');
42 42
 
43
-        return $mod;
44
-    }
43
+		return $mod;
44
+	}
45 45
 
46
-    public function &grabEntries(&$obj)
47
-    {
48
-        $ret = false;
49
-        require XOOPS_ROOT_PATH . '/modules/references/include/common.php';
50
-        $start      = 0;
51
-        $limit      = $this->grab;
52
-        $items      = $h_references_articles->getRecentArticles($start, $limit);
53
-        $i          = 0;
54
-        $categories = $h_references_categories->getCategories();
46
+	public function &grabEntries(&$obj)
47
+	{
48
+		$ret = false;
49
+		require XOOPS_ROOT_PATH . '/modules/references/include/common.php';
50
+		$start      = 0;
51
+		$limit      = $this->grab;
52
+		$items      = $h_references_articles->getRecentArticles($start, $limit);
53
+		$i          = 0;
54
+		$categories = $h_references_categories->getCategories();
55 55
 
56
-        if (false != $items && count($items) > 0) {
57
-            foreach ($items as $item) {
58
-                $ret[$i]['link']        = $item->getUrl();
59
-                $ret[$i]['title']       = $item->getVar('article_title');
60
-                $ret[$i]['timestamp']   = $item->getVar('article_timestamp');
61
-                $ret[$i]['description'] = references_utils::truncate_tagsafe($item->getVar('article_text'), REFERENCES_SHORTEN_TEXT);
62
-                $categoryId             = $item->getVar('article_category_id');
63
-                $ret[$i]['category']    = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : '';
64
-                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
65
-                ++$i;
66
-            }
67
-        }
56
+		if (false != $items && count($items) > 0) {
57
+			foreach ($items as $item) {
58
+				$ret[$i]['link']        = $item->getUrl();
59
+				$ret[$i]['title']       = $item->getVar('article_title');
60
+				$ret[$i]['timestamp']   = $item->getVar('article_timestamp');
61
+				$ret[$i]['description'] = references_utils::truncate_tagsafe($item->getVar('article_text'), REFERENCES_SHORTEN_TEXT);
62
+				$categoryId             = $item->getVar('article_category_id');
63
+				$ret[$i]['category']    = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : '';
64
+				$ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
65
+				++$i;
66
+			}
67
+		}
68 68
 
69
-        return $ret;
70
-    }
69
+		return $ret;
70
+	}
71 71
 }
Please login to merge, or discard this patch.