Unable to run the Stream API sample #144
Labels
No labels
Bug
Enhancement
Feature Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: code/twython#144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi, I'm testing the stream API sample code here https://github.com/ryanmcgrath/twython, but keep getting this error: line 560, in stream TwythonError: 'Response was not valid JSON, unable to decode.' Any help is appreciated.
This is similar to Issue 110. I ended up just repeating the same procedure in the streaming method.
The basic issue here is why this method can't retrieve valid streaming data as it supposes to do. I'd like to retrieve the tweets within a specific geographic area. After googling around, I didn't find many useful samples. I thought the stream API can do it but got stuck here. Are there any alternatives to do it?
I messed around with the Stream API the other day and it was indeed broken. I'm working on a fix for it. Sorry for any inconvenience!
Good news! I actually figured out the problem, BUT I'm in a little need of help thinking of the best way to structure the Streaming API calls since there is more than just POSTing now.
@ryanmcgrath any ideas?
Right now, we're always doing
requests.postin the stream, BUT there are endpoints that require GET (i.e. https://dev.twitter.com/docs/api/1.1/get/user)streamwill no longer be astaticmethod, instead it must be on the Twython class because all streams now require OAuth authentication rather than XAuth.Mmm, I'd personally just offer two Classes to import - ala, a
Twythonand aTwythonStreameror something. From what experiences I have with the Streaming API it has its own logic that is possibly worth just keeping somewhat separate.Hmmm, alright; I'm still having trouble thinking of the best way to implement it though.
That's about where I'm at, haha.
I'm trying to think of the best way to make the
streammethod as dynamic as possible; or do we want to do like:Hey,
Anyone interested in this issue, we're looking for feedback on this approach to the Streaming API. It's kind of taking a cue from Django's class based views - the thought is to localize the number of callbacks and logic surrounding dealing with the nature of the streaming API itself:
Well, it's been a week. We should go with this approach unless someone can indicate to me if there's something wrong with it.
@cfu1 @seepel Streaming has been fixed! Changes are in
masterandTwython2.9.0 is now available via PyPi!pip install -I twythonHere is an example how to use the new
TwythonStreamerclass:Any questions, feel free to ask! :)
Installation from pip failed
pip install -I twython
from .streaming import TwythonStreamer
ImportError: No module named streaming
Had to download it from GitHub.
Hmmm, I just tried this and can't reproduce the error. The following code
has problems for you?
I just reproduced this. On sec
Needed to add
to
setup.pyI believe. I'll push the new pep8 stuff along with this soon.Try it now @sladiwala! :D
Works! Thanks for the quick turnaround.
Ps @sladiwala, let us know if you find working with our Streaming API simple to understand! :)
I was playing around with the same streaming example itself. Following is my piece of code:
However, I was getting a 406 error as follows:
406 Parameter follow has unparseable items harisibrahimkv
406 Unable to decode response, not vaild JSON.
I thought the follow variable was supposed to take Twitter usernames as values and return their real time tweets. Please see if this is a bug. If not, I am ready to get scolded. :)
@harisibrahimkv It's because the follow parameter takes in user ids as values and not usernames. Lucky for us it isn't difficult to get the user id for a given username:
Oh, ID literally meant a number huh? Maybe this should have been hinted in the documentation. Would be helpful to noobs.
Thanks again. I would have gone nuts trying to figure out how to get the user ID if you had not mentioned it.
Yes, it takes the IDs. Sorry about the wrong example. You can use track=yourusername
Although!! Until requests pushes a new update, all streams following users who don't get a lot of interaction will be one post behind. :( (there is an issue out for this in twython you can go check what exactly is going on) it will hopefully be merged soon though!
Sent from my iPhone
so im trying to stream and I'm using the exact same code as above, ive used Twython before to fetch data using the search function...
from twython import TwythonStreamer
class MyStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
print data['text'].encode('utf-8')
stream = MyStreamer(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
stream.statuses.filter(track='#fashion')
but i am not seeing any data....