简体   繁体   English

如何从Instagram API获取'id'参数?

[英]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 ? 有人可以告诉我“如何获取”或“是什么”在ruby instagram api方法中使用的“ id”参数location(id), location_recent_media(id,options{}), media_item(id), media_likes(id)等在院子文档http://rubydoc.info/github/Instagram/instagram-ruby-gem中给出 I am using rails and the api is installed using gem. 我正在使用rails,并且使用gem安装了api。

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. 您可以在此处https://github.com/Instagram/instagram-ruby-gem上看到如何使用API​​的示例,看看代码,我会说id取决于您要查询的内容,如果您正在使用location(id),它将是位置的ID。 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): 现在,要从“现实世界”位置获取该ID,我相信您可以使用location_search(经度,纬度),这将为您提供一个数组,其中所有位置都靠近该坐标,例如(来自代码文档):

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). 这样就可以为您提供一个阵列,其位置在37.7808851,-122.3948632(164 S Park,SF,CA USA)附近。

Then you can use that array of ids with location(id), eg: 然后,您可以将ID数组与location(id)一起使用,例如:

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

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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