Instagram API获取带有地理标记的照片的位置数据

时间:2016-03-11 06:49:31

标签: python instagram instagram-api

是否可以使用InstagrampythonInstagram API上检索照片被标记的商家或地点的位置数据?

我一直在为自己的帐户使用access token并安装了Python Instagram

1 个答案:

答案 0 :(得分:0)

您应该使用get_media请求查询图片以获取其位置详细信息。

如果图片是地理标记的,则响应将包含位置详细信息,如下所示:

"location":  {
    "latitude": 40.417044464,
    "name": "Puerta del Sol Madrid",
    "longitude": -3.703540741,
    "id": 3002373
}

要使用python获取此数据,请使用Python-Instagram包并致电api.media

import instagram

# Fill in access token here and image id
access_token = ''
media_id = ''
api = instagram.client.InstagramAPI(access_token=access_token)
res = api.media(media_id)
print res.location

# You should get a Location object with a latitude and a longitude point
>> Location: 3002373 (Point: (40.417044464, -3.703540741))