问题
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.
Take for example the following request:
curl 'https://api.instagram.com/v1/media/search?lat=51.508515&lng=-0.12548719999995228&max_timestamp=1400700973&distance=5000&access_token=XXXXXXXXXX'
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"
}
(I used jq
(http://stedolan.github.io/jq/) to parse out the created_times of all of the results)
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?
回答1:
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...
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)
来源:https://stackoverflow.com/questions/23792774/instagram-api-media-search-endpoint-not-respecting-max-timestamp-parameter