MCPcopy Index your code
hub / github.com/ryanmcgrath/twython / Twython

Class Twython

twython/api.py:31–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30
31class Twython(EndpointsMixin, object):
32 def __init__(self, app_key=None, app_secret=None, oauth_token=None,
33 oauth_token_secret=None, access_token=None,
34 token_type='bearer', oauth_version=1, api_version='1.1',
35 client_args=None, auth_endpoint='authenticate'):
36 """Instantiates an instance of Twython. Takes optional parameters for
37 authentication and such (see below).
38
39 :param app_key: (optional) Your applications key
40 :param app_secret: (optional) Your applications secret key
41 :param oauth_token: (optional) When using **OAuth 1**, combined with
42 oauth_token_secret to make authenticated calls
43 :param oauth_token_secret: (optional) When using **OAuth 1** combined
44 with oauth_token to make authenticated calls
45 :param access_token: (optional) When using **OAuth 2**, provide a
46 valid access token if you have one
47 :param token_type: (optional) When using **OAuth 2**, provide your
48 token type. Default: bearer
49 :param oauth_version: (optional) Choose which OAuth version to use.
50 Default: 1
51 :param api_version: (optional) Choose which Twitter API version to
52 use. Default: 1.1
53
54 :param client_args: (optional) Accepts some requests Session parameters
55 and some requests Request parameters.
56 See http://docs.python-requests.org/en/latest/api/#sessionapi
57 and requests section below it for details.
58 [ex. headers, proxies, verify(SSL verification)]
59 :param auth_endpoint: (optional) Lets you select which authentication
60 endpoint will use your application.
61 This will allow the application to have DM access
62 if the endpoint is 'authorize'.
63 Default: authenticate.
64 """
65
66 # API urls, OAuth urls and API version; needed for hitting that there
67 # API.
68 self.api_version = api_version
69 self.api_url = 'https://api.twitter.com/%s'
70
71 self.app_key = app_key
72 self.app_secret = app_secret
73 self.oauth_token = oauth_token
74 self.oauth_token_secret = oauth_token_secret
75 self.access_token = access_token
76
77 # OAuth 1
78 self.request_token_url = self.api_url % 'oauth/request_token'
79 self.access_token_url = self.api_url % 'oauth/access_token'
80 self.authenticate_url = self.api_url % ('oauth/%s' % auth_endpoint)
81
82 if self.access_token: # If they pass an access token, force OAuth 2
83 oauth_version = 2
84
85 self.oauth_version = oauth_version
86
87 # OAuth 2
88 if oauth_version == 2:

Callers 10

setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
follow_user.pyFile · 0.90
search_results.pyFile · 0.90
update_status.pyFile · 0.90

Calls

no outgoing calls

Tested by 4

setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72