如何在instagram api上找到用户位置? instagram端点有这个uri:https://api.instagram.com/v1/locations/ {location-id}?访问令牌= ACCESS-TOKEN
答案 0 :(得分:4)
您可以通过利用媒体订阅源上的位置服务来估算用户的位置。也就是说,您可以从一个或多个所需用户的发布图像中提取位置标记。然后,您可以使用所有用户的图像来提供大致的位置或类似的内容。
请注意,并非每个图片都有位置标记,并且某些用户的位置服务已完全关闭,在这种情况下,不会标记任何图片。但你可以这样做:
使用具有位置的@ instagram图像之一的图像ID。然后使用python库连接到instagram api以获取该图像的信息。然后访问图像位置。
image_id = '976907440786573124_25025320'
image_info = api.media(image_id)
lat = image_info.location.point.latitude
lon = image_info.location.point.longitude
print (lat,lon)
给出结果(51.565501504,-0.089821461)
答案 1 :(得分:0)
要添加到jstnstwrt的答案,最直接的方法是:
如果为python安装python-instagram libary,则可以执行以下操作:
import instagram
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
id = <id of the user you're trying to get location from>
location = api.location(id) # returns error if no location set
coordinates = location.point #returns point object with lat and long coordinates