Ajax call to Instagram (GET /media/search) timestamp issue

徘徊边缘 提交于 2019-12-11 19:05:46

问题


I'm Getting 400 bad request as a response:

{"meta":{"error_type":"APIInvalidParametersError","code":400,"error_message":"invalid parameters-check the max\/min-timestamps, if you supplied them"}}

while my request seem to be fine:

https://api.instagram.com/v1/media/search?q=demonstration&lat=30.0444&lng=31.2357&distance=1000&min_timestamp=1383253200000&max_timestamp=1385758800000&access_token=9xxx4

specifying timestamps with a range of a month, is that an issue?

P.S. Using JQuery 1.9.1

Thanks,


回答1:


Just remove the last three 0s in your timestamp and it will work, I just tested this and it works

your timestamp is in miliseconds, it should be in seconds, you have to do time/1000.

https://api.instagram.com/v1/media/search?q=demonstration&lat=30.0444&lng=31.2357&distance=1000&min_timestamp=1383253200&max_timestamp=1385758800&access_token=9xxx4

Here is a implementation I have done for this API with timestamp change: http://www.gramfeed.com/instagram/map

(I dont think there is a 7 day limit, i can go back 30+ days before and get results)




回答2:


From the docs:

The time span must not exceed 7 days.

Don't forget that a Unix timestamp is seconds since the epoch. So in JS you'd do:

Math.round(new Date.getTime() / 1000 );


来源:https://stackoverflow.com/questions/21091543/ajax-call-to-instagram-get-media-search-timestamp-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!