By Dan Nguyen
Everyone who tweets at my bot with an address and the hashtag
#showme will be tweeted back the most interesting recent Instagram photo near that address.
For example, a Tweet that looks like this:
@samplebot #showme Tokyo, Japan
– will respond with:
@user Here's an interesting photo near Tokyo, Japan [instagramlink]
- Bot checks Twitter API endpoint of statuses/mentions_timeline
- For each Tweet, the bot to see if the #showme hashtag was used. Also, note the user's screen name and the ID of the tag.
- Getting the location: The location to look up is either the other text in that tweet. Or, if the tweet has geolocation enabled, we use those coordinates.
- If the location is an address string, use the Google Maps geocoding API to get lat/lng coordinates.
- Use Instagram's media/search endpoint and pass in the lat/lng coordinates.
- From Instagram's request, choose the highest photo based on number of Likes.
- Extract the image's web link
- Use Twitter's statuses/update endpoint and reply back to the user with the Instagram URL.