简体   繁体   中英

How to get 'id' parameter from the instagram api?

Can someone tell me "how to get" or "what is" the 'id' parameter that is used in the ruby instagram api methods location(id), location_recent_media(id,options{}), media_item(id), media_likes(id) etc given in the yard documentation http://rubydoc.info/github/Instagram/instagram-ruby-gem ? I am using rails and the api is installed using gem.

You can see an example of how to use the API in here https://github.com/Instagram/instagram-ruby-gem , taking a look at the code I would say that the id is dependent on what you are querying, if you are using location(id) it would be the id of the location. Now, to get from a "real world" location to that id I believe you can use location_search(longitude, latitude) and that would give you an array with all the locations close to that coordinates, eg (from the code documentation):

Instagram.location_search("37.7808851", "-122.3948632")

That would give you an array with the locations around 37.7808851, -122.3948632 (164 S Park, SF, CA USA).

Then you can use that array of ids with location(id), eg:

mylocations = Instagram.location_search("37.7808851", "-122.3948632")
Instagram.location(mylocations.first)

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM