python-twitter icon indicating copy to clipboard operation
python-twitter copied to clipboard

GetSearch return_json error

Open williamstrong opened this issue 7 years ago • 8 comments

When I try to run: search_results = api.GetSearch(term=q, count=count, return_json=True)

I get this error: TypeError: GetSearch() got an unexpected keyword argument 'return_json'

I've looked through the source code but I do not understand what the issue it. According to the documentation and source return_json should be a valid argument

williamstrong avatar Sep 11 '17 06:09 williamstrong

I get the same issue.

thejoltjoker avatar Sep 12 '17 00:09 thejoltjoker

I found out that the documentation is v3.2 and the current version is 3.3

williamstrong avatar Sep 12 '17 02:09 williamstrong

I don't think that the latest master branch has been uploaded to pypi.

@bear time for an update?

jeremylow avatar Sep 14 '17 03:09 jeremylow

@williamstrong @thejoltjoker check this link here https://dev.twitter.com/rest/reference/get/search/tweets the twitter has removed the return_json argument from its API so it's obvious that you will get an error.If you want to get data in JSON format then make a dictionary from the key-value pairs using zip function or simply by dictionary_name['key'] = value them import the JSON and dump that dictionary into it. You will get the required result.

Satyam-Bhalla avatar Sep 23 '17 15:09 Satyam-Bhalla

Hey I'm kind of new to this, trying to use getSearch and it's not giving me an error but it's just returning an empty array?

aadon94 avatar Sep 30 '17 15:09 aadon94

@aadon94 Can you create a new issue? I assume that the problem is that the search isn't returning any results, but I can help you work through that. Also, do issues https://github.com/bear/python-twitter/issues/482 and https://github.com/bear/python-twitter/issues/478 address your issue?

jeremylow avatar Oct 05 '17 01:10 jeremylow

@Satyam-Bhalla I resulted to iterating through the returned list and calling the method AsJsonString() on each object.

williamstrong avatar Oct 05 '17 02:10 williamstrong

@williamstrong You can also access the raw json for each object by using its ._json attribute. So like for a series of tweets:

tweets = api.GetSearch(term="twitter")
for tweet in tweets:
    do_something(tweet._json)

jeremylow avatar Oct 05 '17 02:10 jeremylow