Skip to content

Commit 8bd2bda

Browse files
author
gregr
committed
Twitter streaming API is now SSL only.
1 parent d7adf44 commit 8bd2bda

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

twitter-oauth-streaming.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
22
import oauth2 as oauth
33
import urlparse, time, webbrowser
4-
from twisted.internet import reactor, protocol
4+
from twisted.internet import reactor, protocol, ssl
55
from twisted.web import http
66

77
CONSUMER_KEY='CHANGEME'
@@ -98,7 +98,7 @@ def fetch_access_token():
9898
return (access_token['oauth_token'], access_token['oauth_token_secret'])
9999

100100
def build_authorization_header(access_token):
101-
url = "http://%s%s" % (TWITTER_STREAM_API_HOST, TWITTER_STREAM_API_PATH)
101+
url = "https://%s%s" % (TWITTER_STREAM_API_HOST, TWITTER_STREAM_API_PATH)
102102
params = {
103103
'oauth_version': "1.0",
104104
'oauth_nonce': oauth.generate_nonce(),
@@ -135,5 +135,5 @@ def build_authorization_header(access_token):
135135

136136
# Twitter stream using the Authorization header.
137137
twsf = TwitterStreamerFactory(auth_header)
138-
reactor.connectTCP(TWITTER_STREAM_API_HOST, 80, twsf)
138+
reactor.connectSSL(TWITTER_STREAM_API_HOST, 443, twsf, ssl.ClientContextFactory())
139139
reactor.run()

0 commit comments

Comments
 (0)