Return dict of response received from Twitter's API :param endpoint: (required) Full url or Twitter API endpoint (e.g. search/tweets) :type endpoint: string :param method: (optional) Method of accessing data, either GET, POST o
(self, endpoint, method='GET', params=None, version='1.1', json_encoded=False)
| 237 | return error_message |
| 238 | |
| 239 | def request(self, endpoint, method='GET', params=None, version='1.1', json_encoded=False): |
| 240 | """Return dict of response received from Twitter's API |
| 241 | |
| 242 | :param endpoint: (required) Full url or Twitter API endpoint |
| 243 | (e.g. search/tweets) |
| 244 | :type endpoint: string |
| 245 | :param method: (optional) Method of accessing data, either |
| 246 | GET, POST or DELETE. (default GET) |
| 247 | :type method: string |
| 248 | :param params: (optional) Dict of parameters (if any) accepted |
| 249 | the by Twitter API endpoint you are trying to |
| 250 | access (default None) |
| 251 | :type params: dict or None |
| 252 | :param version: (optional) Twitter API version to access |
| 253 | (default 1.1) |
| 254 | :type version: string |
| 255 | :param json_encoded: (optional) Flag to indicate if this method should send data encoded as json |
| 256 | (default False) |
| 257 | :type json_encoded: bool |
| 258 | |
| 259 | :rtype: dict |
| 260 | """ |
| 261 | |
| 262 | if endpoint.startswith('http://'): |
| 263 | raise TwythonError('api.twitter.com is restricted to SSL/TLS traffic.') |
| 264 | |
| 265 | # In case they want to pass a full Twitter URL |
| 266 | # i.e. https://api.twitter.com/1.1/search/tweets.json |
| 267 | if endpoint.startswith('https://'): |
| 268 | url = endpoint |
| 269 | else: |
| 270 | url = '%s/%s.json' % (self.api_url % version, endpoint) |
| 271 | |
| 272 | content = self._request(url, method=method, params=params, |
| 273 | api_call=url, json_encoded=json_encoded) |
| 274 | |
| 275 | return content |
| 276 | |
| 277 | def get(self, endpoint, params=None, version='1.1'): |
| 278 | """Shortcut for GET requests via :class:`request`""" |