iOS Twitter API; How to retrieve the most recent t

2019-07-10 08:01发布

问题:

I am new to the Twitter API and iOS, but reading the documentation I learned to use the "Twitter.framework" in xCode and the "TWRequest" class in specific.

The most obvious way to go would be to make a request to:

GET statuses/public_timeline

However that request does not allow a parameter to specify a latitude and a longitude to get the most recent public tweets within a country. I did find:

GET geo/search

Which allows me to set all kind of cool parameters such as lat, long and granularity, but unfortunately it does not return tweets in the results.

So is it possible? Or a lost cost?


Edit:

So I guess I should be using:

GET search

But the only downfall is that I should give a q (query), a search term, but I am not searching for a specific term. I just like to retrieve the most recent public tweets in a given country. So is there, and should I use, a wildcard?

回答1:

First make a request to:

GET geo/search

To get the place ID. For The Netherlands the ID is 879d7cfc66c9c290.

Then make a search request to:

GET search

With the query:

q=place:{PLACE_ID} 

Example: "q=place:879d7cfc66c9c290"

If you like to get the most recent you can also set a parameter called result_type and set it to recent and that's it. Hope it helps people.