无效的 Flickr API 响应 [英] Invalid Flickr API response

查看:23
本文介绍了无效的 Flickr API 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Flickr API 上遇到了一个非常令人费解的问题.基本上,我(和一些开发人员朋友)可以运行某些查询,这会导致结果集损坏.

I've come across a very puzzling issue with the Flickr API. Basically, there's certain queries I (and some developer friends) can run which result in broken resultsets.

基本上,您请求的内容并不总是返回...

Basically, what you request, isn't always returned...

这里有几个例子:

请求:

http://api.flickr.com/services/rest/?method=flickr.photos.search&safe_search=1&media=photos&extras=o_dims&per_page=30&page=1&format=json&nojsoncallback=1&api_key=XXXXXXXX

回复:

HTTP/1.1 200 OK
Content-Length: 793
Date: Thu, 05 Jan 2012 23:30:56 GMT
P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
Access-Control-Allow-Origin: *
Cache-Control: private
X-Served-By: www71.flickr.mud.yahoo.com
Vary: Accept-Encoding
Connection: close
Content-Type: text/plain; charset=utf-8

{"photos":{"page":1, "pages":19886, "perpage":30, "total":"596560", "photo":[{"id":"6643915631", "owner":"74181952@N00", "secret":"8bc611c556", "server":"7023", "farm":8, "title":"IMG_5642", "ispublic":1, "isfriend":0, "isfamily":0}, {"id":"6643911681", "owner":"7240073@N04", "secret":"34837024f0", "server":"7004", "farm":8, "title":"26 weeks!!", "ispublic":1, "isfriend":0, "isfamily":0, "o_width":"768", "o_height":"1024"}, {"id":"6643919177", "owner":"54899865@N02", "secret":"170d3a336f", "server":"7153", "farm":8, "title":"IMGA0072", "ispublic":1, "isfriend":0, "isfamily":0}, {"id":"6643916265", "owner":"51191328@N06", "secret":"05905197ce", "server":"7034", "farm":8, "title":"IMG_1781", "ispublic":1, "isfriend":0, "isfamily":0, "o_width":"2736", "o_height":"3648"}]}, "stat":"ok"}

请注意,当我们要求 30 个时,只返回了 4 个图像?(有 596560 张图片匹配)

Notice there's only 4 images returned, when we asked for 30? (and there's 596560 pics matching)

如果我将每页计数更改为不同的值,它可能会起作用,就像现在一样,如果我将其更改为 3,它将返回 3,但是昨天当我进行测试时,它只返回 2!当我将其更改为 10 时,它没有返回任何内容!?

If I change the perpage count to something different it may work, like right now, if I change it to 3, it'll return 3, but yesterday when I was testing, it only returned 2! and when I changed it to 10 it returned none!?

我们遇到了另一个例子,这次是图像大小数据:

We've come across another example, this time with image size data:

请求

http://api.flickr.com/services/rest/?method=flickr.interestingness.getList&extras=o_dims&per_page=3&page=1&format=rest&api_key=XXXXXXXXXX

回复

<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<photos page="1" pages="167" perpage="3" total="500">
    <photo id="6743082503" owner="29789996@N00" secret="7d6a1ab340" server="7165" farm="8" title="Glittering Marina [2]" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="6741988715" owner="44789014@N04" secret="ab1528fa9f" server="7009" farm="8" title="Heavy metal warrior" ispublic="1" isfriend="0" isfamily="0" o_width="1200" o_height="1202" />
    <photo id="6741320397" owner="54880604@N06" secret="7b3bd8530f" server="7030" farm="8" title="Greetings from below, Village near Can Tho" ispublic="1" isfriend="0" isfamily="0" />
</photos>
</rsp>

注意只有一张图片有图片尺寸数据.

Note only one of the images has image size data.

这是一个很难重现的问题,因为它只是时不时地发生,但是一旦您发现导致问题的页面/页面计数组合,您将始终得到不正确的响应(我认为这是由于某些原因造成的)缓存的形式).

It's a very difficult issue to reproduce as it only happens every now and then, but once you've found a page/pagecount combo that causes an issue, you'll consistently get the incorrect response (I assume it's due to some form of caching).

有没有其他人遇到过这个?正如您在我上面的结果集中看到的,没有错误,没有警告,只有不正确的响应.

Has anyone else come across this? As you can see in my resultset above, there's no error, no warning, just an incorrect response.

提前致谢.亚伦

推荐答案

嗯.我给自己提交了一个错误;让我研究一下.可能是我们的分页错误,或者建议的缓存内容.

Huh. I've filed myself a bug; let me look into it. Possibly a pagination bug on our end, or a caching thing as suggested.

这篇关于无效的 Flickr API 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆