2015-02-11 194 views

回答

4

您可以通过在媒体饲料利用位置服务接近用户的位置。也就是说,您可以从一个或多个所需用户张贴的图像中提取位置标记。然后,您可以使用所有用户的图像来获得大概的位置或类似的东西。

请注意,并非所有图像都有位置标记,并且某些用户的位置服务完全关闭,在这种情况下,将不会标记图像。但你可以这样做:

使用图像ID为@ instagram的图像之一有一个位置。然后使用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)

+0

这是辉煌,配合 – 2016-02-06 00:20:03

0

要添加到jstnstwrt的回答,最直接的方法是:

如果您安装蟒蛇蟒蛇,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 
+0

jstnstwrt提到从媒体ID而不是用户ID接收的位置。我不认为api会返回用户的位置 – potatoes 2017-12-07 08:48:04