I am having a bit of trouble sifting through the twitter API. I am trying to search for tweets near a certain location and then see their exact (or approximate) geo coordinates. I understand the geo field is deprecated and now we are supposed to use the "place" field. Unfortunately when I use the following url: http://search.twitter.com/search.json?q=&geocode=30.1829,-97.832,10mi I get a bunch of responses with a location that matches the city of the geo coordinates, but geo: is null and there is no place field. Am I stuck with only having an accuracy up to city coordinates, or am I using the wrong search call?
Thanks in advance!
Remember, tweeting with a geo location is an opt-in process. Twitter will supply a feed from the area for all tweeters in that area, but only those who have opted to tweet their coordinates will show up with "geo" info.
Using q=here with your url it did return 1 tweet for me with "geo" info in this form (though likely it will have moved on down the timeline by the time you try...):
"geo":{"coordinates":[-33.9769,18.5080],"type":"Point"}
Every user has a user defined location set in their profile settings. Use this when users don't use geo-encoding.
You can obtain a list of all countries / states by country and do a simple clean-up operation on the dataset.
This gave me what I needed for location data and greatly enriched my output.
Related
My company gets the addresses the loading hubs for our freights every week. We need to geocode them into coordinates. But often the addresses either are incomplete or contain minor grammar mistakes, so it's impossible to input them for geocoding.
My question : when dealing with a list of wrong or incomplete addresses when geocoding, is there any general solution to solve the issue ?
If there are useful articles or resources about this topic, please let me know.
Thank you.
Geocoding / Autocomplete
According to the Geocoding Addresses Best Practices documentation:
"Geocoding is the process of converting addresses (like a street address) into geographic coordinates (latitude and longitude), which you can use to place markers on a map, or position the map."
"In general, use the Geocoding API when geocoding complete addresses (for example, “48 Pirrama Rd, Pyrmont, NSW, Australia”). Use the Places API Place Autocomplete service when geocoding ambiguous (incomplete) addresses."
The Place Autocomplete service returns place predictions according to your inputs. This would solve your problem of having wrongly spelled addresses.
How to get the coordinates after using Place Autocomplete?
example request for Place Autocomplete would look like this:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Paris&types=geocode&key=YOUR_API_KEY
The Place Autocomplete is able to return the address description together with its place_id. In this sample request, you are able to get "description": "Paris, France" with a "place_id": "ChIJD7fiBh9u5kcRYJSMaMOCCwQ".
Then you can use the Place ID of the predicted location to obtain the coordinates of that place by using Place Details request
You can request it like this:
https://maps.googleapis.com/maps/api/place/details/json?fields=geometry&place_id=ChIJD7fiBh9u5kcRYJSMaMOCCwQ&key=YOUR_API_KEY
We used here the fields=geometry to only return the coordinates of the location and as previously mentioned the Place ID we used is the one we had from the Autocomplete query.
The returned data will be the expected result according to your question. But feel free to comment if you need anything.
To read more about the fields parameter, refer to the Place Details documentation.
I hope this helps!
I use the url to search channels in a specific country like this https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=8&order=viewCount&q=news&type=channel®ionCode=US&key=API-Key.
But when i changed the regionCode parameter to IT(italy) or any other one,the search result is always identical.So the search result is not changed with the regionCode.
How can I search the channel by country using the YouTube API 3.0,thanks.
I also try to search channel with the optional parameter regionCode, and it seems that this parameter is not to filter the results base on the country code of a Country. I found in this related SO question that the region parameter only applies to movie charts, and is not something that works as a parameter for general searches.
So the only possible parameter that I think you can use to filter the results of YouTube API in a specific country or place is by using the parameter location.
The location parameter, in conjunction with the locationRadius parameter, defines a circular geographic area and also restricts a search to videos that specify, in their metadata, a geographic location that falls within that area. The parameter value is a string that specifies latitude/longitude coordinates e.g. (37.42307,-122.08427).
Hope it helps you.
There is no way to solve this problem. I tried location with locationRadius, but second parameter is limited to 1000km, so, I cant find all videos from Russian Federation or USA using that option and 1 api request.
Also, that api request performs slow for understandable reason.
I´ve been reading the documentation of the Google Maps SDK for iOS and I didn't see anything about voice navigation direction and route on the map.
Do anyone know about this?
I correct my previous answer this is possible. You use the google directions API as outlined in this link:
You send your direction request and it returns the directions either as json or xml as per your preference. Gives you coordinates of each point on the route.
You send a request to http://maps.googleapis.com/maps/api/directions/outputformat?parameters
So if you want to return the directions as json the request would be:
http://maps.googleapis.com/maps/api/directions/json?origin=ORIGIN_LOCATION&destination=DESTINATION_LOCATION&sensor=FALSE
the ORIGIN_LOCATION and DESTINATION_LOCATION can either be a latitude and longitude seperated by a comma e.g. latitude,longitude or a location search string e.g Eiffel+Tower+,+Paris+France (The search string has to be url encoded).
The sensor parameter is another compulsory parameter and asks whether the device sending the request can detect its own location.
For example for the directions from the eiffel tower to the louvre museum are given on the following link as json:
http://maps.googleapis.com/maps/api/directions/json?origin=Louver+museum+Paris&destination=Eiffel+Tower+Paris+France&sensor=false
And to return it as XML:
http://maps.googleapis.com/maps/api/directions/xml?origin=Louver+museum+Paris&destination=Eiffel+Tower+Paris+France&sensor=false
How can I find the location of a specific user's tweet? What are the API methods and techniques that I need to go through to determine the location?
Note: The below assumes that you want to grab multiple tweets and find their locations. If you don't, and you just want a single tweet by it's id, use statuses/show.
It's entirely possible - if the user has enabled location for their tweet. It'll be the value of the coordinates key, which will be null if they haven't.
Let's say you're using the following API method: statuses/user_timeline.
This is a GET request
The resource url is: https://api.twitter.com/1.1/statuses/user_timeline.json
You can specify either the user_id or screen_name as part of the GET parameters, for example: ?screen_name=J7mbo.
In the tweet results, once json_decode() is run on them, one of the keys will look like this:
This is actually the first key, according to the documentation, so you should be able to find it and it's value pretty easily.
Warning
Do not get confused with the location sub-key underneath the User key. This is the location of the user, as per their profile, not the location of any specific tweet. Use the coordinates key for that.
Documentation Link
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?
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.