我们正在使用FB Android SDK RequestBatch :: executeAndWait()将批量请求发送到retrive一些有关照片的信息。此批次中的请求数小于50.但是,有时我们会看到抛出异常:FacebookException: Unexpected number of results
。
进一步调查显示抛出的异常是Request::createResponseFromObject
方法。
if (!(object instanceof JSONArray) || ((JSONArray) object).length() != numRequests) {
FacebookException exception = new FacebookException("Unexpected number of results");
throw exception;
}
在某些Android设备上并不总是随机抛出此异常,并不总是在同一个查询上。关于为什么会发生这种情况的任何线索都非常有用。
以下是批量请求示例。
- 请求:
- Id:42
- 网址:https://graph.facebook.com
- 方法:POST
- 用户代理:FBAndroidSDK.3.6.0
- 内容类型:multipart / form-data;边界= 3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f
- batch_app_id:APP_ID
- 批次[{
" relative_url":" SOME_PHOTO_ID1?access_token = ACCESS_TOKEN& fields = images,place.fields(id)& format = json& sdk = android",
"方法":" GET"
},{
" relative_url":" SOME_PHOTO_ID2?access_token = ACCESS_TOKEN& fields = images,place.fields(id)& format = json& sdk = android",
"方法":" GET"
},{
" relative_url":" SOME_PHOTO_ID3?access_token = ACCESS_TOKEN& fields = images,place.fields(id)& format = json& sdk = android",
"方法":" GET"
},{
" relative_url":" SOME_PHOTO_ID4?access_token = ACCESS_TOKEN& fields = images,place.fields(id)& format = json& sdk = android",
"方法":" GET"
},....更多此类请求< 50
]
响应如下:Sorry, something went wrong. We're working on it and we'll get it fixed as soon as we can.
请参阅下面的示例。
!http://www.weliveinbritain.co.uk/wp-content/uploads/2012/11/ss-facebook1.png
问题是这个异常是随机抛出的,并不总是在同一个查询中。所以不能始终如一地重复。任何有关可能原因的帮助都将深受赞赏。