Instagram API媒体/搜索端点不遵守max_timestamp参数 [英] Instagram API media/search endpoint not respecting max_timestamp parameter
问题描述
根据Instagram API文档,在对/media/search
终结点的调用中添加max_timestamp
参数应仅返回时间戳小于max_timestamp
的结果(
According to the Instagram API documentation, adding a max_timestamp
parameter to calls to the /media/search
endpoint should only return results who's timestamps are less than the max_timestamp
(http://instagram.com/developer/endpoints/media/#get_media_search). However, this is not always the case.
以以下请求为例:
curl 'https://api.instagram.com/v1/media/search?lat=51.508515&lng=-0.12548719999995228&max_timestamp=1400700973&distance=5000&access_token=XXXXXXXXXX'
我提供的"max_timestamp"为1400700973,但是当我们查看API的结果时,我们会发现这没有得到遵守:
I am providing a 'max_timestamp' of 1400700973, but when we look at the results from the API we can see that this is not being respected:
{
"created_time": "1400701017"
}
{
"created_time": "1400701016"
}
{
"created_time": "1400701016"
}
{
"created_time": "1400701010"
}
{
"created_time": "1400701009"
}
{
"created_time": "1400701008"
}
{
"created_time": "1400701003"
}
{
"created_time": "1400701000"
}
{
"created_time": "1400700997"
}
{
"created_time": "1400700997"
}
{
"created_time": "1400700994"
}
{
"created_time": "1400700992"
}
{
"created_time": "1400700991"
}
{
"created_time": "1400700991"
}
{
"created_time": "1400700988"
}
{
"created_time": "1400700985"
}
{
"created_time": "1400700984"
}
{
"created_time": "1400700980"
}
{
"created_time": "1400700973"
}
{
"created_time": "1400700973"
}
(我用jq
( http://stedolan.github.io/jq/ )解析出所有结果的created_times)
(I used jq
(http://stedolan.github.io/jq/) to parse out the created_times of all of the results)
我们可以看到,所有结果实际上都在提供的max_timestamp
参数之前.这是Instagram搜索API的问题,还是我做错了什么?
As we can see, all of the results are actually BEFORE the provided max_timestamp
parameter. Is this a problem with the Instagram search API, or am I doing something wrong?
推荐答案
我也遇到了时间戳问题,虽然我不记得确切的解决方案,但我认为您需要同时提供min_timestamp
和max_timestamp
参数,否则您会看到奇怪的结果.如果您愿意的话,我将提供更多详细信息,但现在可以尝试一下……
I had trouble with timestamps also, and while I cannot remember the exact solution, I think you need to provide both min_timestamp
AND max_timestamp
parameters, otherwise you get strange results as you can see. I will provide more detail when I get a chance to go back over my code in this area if you like, but give approach a shot for now...
从内存中,我从最大时间戳中减去了一定数量以用作min_timestamp,然后循环调用直到获得所需的结果数(或尝试进行一定的次数以避免无限循环)
From memory, I subtracted a certain amount off the max timestamp to use as min_timestamp, then looped over the call until I had the desired number of results (or tried a certain number of times to avoid infinite loops)
这篇关于Instagram API媒体/搜索端点不遵守max_timestamp参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!