我正在尝试使用以下代码重建流API的示例
from twython import Twython
from twython import TwythonStreamer
APP_SECRET = 'XXXXX'
APP_KEY = 'XXXXX'
# from https://stackoverflow.com/questions/17091822/ssl-error-in-twython-get
client_args = {
'verify': False
}
twitter = Twython(APP_KEY, APP_SECRET,client_args=client_args)
auth = twitter.get_authentication_tokens()
OAUTH_TOKEN = auth['oauth_token']
OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
print 'OAUTH_TOKEN = \''+auth['oauth_token']+'\''
print 'OAUTH_TOKEN_SECRET =\''+auth['oauth_token_secret']+'\''
print auth['auth_url']
中的client_args提示进行了操作
然而,由于以下错误,我失败了:
---------------------------------------------------------------------------
SSLError Traceback (most recent call last)
<ipython-input-6-c21b30032283> in <module>()
7 APP_KEY = 'XXX'
8 twitter = Twython(APP_KEY, APP_SECRET,client_args=client_args)
----> 9 auth = twitter.get_authentication_tokens()
10 OAUTH_TOKEN = auth['oauth_token']
11 OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
/Users/geoffreystoel/python/anaconda/lib/python2.7/site-packages/twython/api.pyc in get_authentication_tokens(self, callback_url, force_login, screen_name)
267 if callback_url:
268 request_args['oauth_callback'] = callback_url
--> 269 response = self.client.get(self.request_token_url, params=request_args)
270
271 if response.status_code == 401:
/Users/geoffreystoel/python/anaconda/lib/python2.7/site-packages/requests/sessions.pyc in get(self, url, **kwargs)
392
393 kwargs.setdefault('allow_redirects', True)
--> 394 return self.request('GET', url, **kwargs)
395
396 def options(self, url, **kwargs):
/Users/geoffreystoel/python/anaconda/lib/python2.7/site-packages/requests/sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert)
380 'allow_redirects': allow_redirects,
381 }
--> 382 resp = self.send(prep, **send_kwargs)
383
384 return resp
/Users/geoffreystoel/python/anaconda/lib/python2.7/site-packages/requests/sessions.pyc in send(self, request, **kwargs)
483 start = datetime.utcnow()
484 # Send the request
--> 485 r = adapter.send(request, **kwargs)
486 # Total elapsed time of the request (approximately)
487 r.elapsed = datetime.utcnow() - start
/Users/geoffreystoel/python/anaconda/lib/python2.7/site-packages/requests/adapters.pyc in send(self, request, stream, timeout, verify, cert, proxies)
377 except (_SSLError, _HTTPError) as e:
378 if isinstance(e, _SSLError):
--> 379 raise SSLError(e)
380 elif isinstance(e, TimeoutError):
381 raise Timeout(e)
SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
我做错了什么? 其次 - 是否有办法以编程方式获取PIN码?除了点击URL并将其复制粘贴在我的代码中以外的其他内容?