限制使用Blogger API提取的帖子数量(错误400) [英] Limitation in the number of posts to fetch with Blogger API (error 400)
问题描述
我试图使用Blogger API从博客中获取所有帖子。由于某些未知原因,最多可以抓取的帖子数量限制为20个。
如果我尝试以下网址:
我收到以下回复(列出最后20个帖子的预期):
{
items:[
{
title:El Caballero
},
{
title:Unetraverséedefrontière ......étonnante!
},
{
title:Hasta luego querida Argentina!
},
{
title:Dernier jour en Argentine
},
{
title:Humahuaca
$,
{
title:Purmamarca
},
{
title:Tilcara
},
{
title:Premièresgrèves
},
{
title:Le Nord Argentin:Salta
},
{
title:Ca en fait de l'eau toutça...
},
{
title:Un peu de pluie auBrésil
},
{
title:Iguazu
},
{
title:SanJosé
} ,
{
title:AdieuàBuenos Aires
},
{
title:Traversons en Uruguay
},
{
title:RetouràBuenos Aires
},
{
title:Finara de l'aventure Patagonienne
},
{
title:Les fameuses tours nous surprennent
},
{
title:Un peu de pluie pour se changer les idées
,
{
title: ValleFrancés
}
]
}
但是,如果我增加了maxResults参数,
我得到以下错误:
{
错误:{
错误:[
{
domain:global,
reason: 无效,
消息:无效值
}
],
代码:400,
消息:无效值
$ / code>
如何增加发布最大数量的限制我可以购买?
谢谢,
Nicolas
因此,要获取超过20个结果,您必须使用Bloggers引用API中指定的 pageToken
参数。
您的第一个请求应该包含 nextPageToken
,这样你就可以在回复中找到它。
您的第一次请求必须如下所示:
以下是预期结果:
{
nextPageToken: CgkIChignPaz5ycQ-rn0pIfipe8q,
items:[
{
title:El Caballero
},
{
title Unetraverséedefrontière...étonnante!
},
{
title:Hasta luego querida Argentina!
},
{
title:Dernier jour en Argentine
},
{
title:Humahuaca
$,
{
title:Purmamarca
},
{
title:Tilcara
},
{
title:Premièresgrèves
},
{
title:Le Nord Argentin:Salta
},
{
title:Ca en fait de l'eau toutça...
}
]
}
现在您只需要选择nextPageToken:CgkIChignPaz5ycQ-rn0pIfipe8q
in结果并将其包含在您的下一个请求中,如下所示:
结果应显示接下来的20篇文章, `nextPageToken`用于下一个请求。
I am trying to fetch all the post from a blog using the Blogger API. The maximum number of posts to fetch seems to be limited to 20 for some unknown reasons.
If I try this URL:
I get the following response (listing the last 20 post titles as expected):
{
"items": [
{
"title": "El Caballero"
},
{
"title": "Une traversée de frontière… étonnante!"
},
{
"title": "Hasta luego querida Argentina!"
},
{
"title": "Dernier jour en Argentine"
},
{
"title": "Humahuaca"
},
{
"title": "Purmamarca"
},
{
"title": "Tilcara"
},
{
"title": "Premières grèves"
},
{
"title": "Le Nord Argentin: Salta"
},
{
"title": "Ca en fait de l'eau tout ça..."
},
{
"title": "Un peu de pluie au Brésil"
},
{
"title": "Iguazu"
},
{
"title": "San José"
},
{
"title": "Adieu à Buenos Aires"
},
{
"title": "Traversons en Uruguay"
},
{
"title": "Retour à Buenos Aires"
},
{
"title": "Fin de l'aventure Patagonienne"
},
{
"title": "Les fameuses tours nous surprennent"
},
{
"title": "Un peu de pluie pour se changer les idées"
},
{
"title": "Valle Francés"
}
]
}
However, if I increase the maxResults parameters,
I get the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
How could I increase the limitation in the maximum number of post that I can fetch?
Thanks,
Nicolas
I think that the API is limited to only pull 20 results as a maximum.
So in order to fetch more than 20 results you have to use the pageToken
parameter as specified in Bloggers's reference API.
Your first request should include the nextPageToken
so you will have it in the response. Than use this token to retrieve the next page and so on.
Your first request must be like this :
Here is the expected result :
{
"nextPageToken": "CgkIChignPaz5ycQ-rn0pIfipe8q",
"items": [
{
"title": "El Caballero"
},
{
"title": "Une traversée de frontière… étonnante!"
},
{
"title": "Hasta luego querida Argentina!"
},
{
"title": "Dernier jour en Argentine"
},
{
"title": "Humahuaca"
},
{
"title": "Purmamarca"
},
{
"title": "Tilcara"
},
{
"title": "Premières grèves"
},
{
"title": "Le Nord Argentin: Salta"
},
{
"title": "Ca en fait de l'eau tout ça..."
}
]
}
Now all you have to do is to pick the "nextPageToken": "CgkIChignPaz5ycQ-rn0pIfipe8q"
in the result and include it in you next request like this :
The result should show the next 20 posts in addition to a new ``nextPageToken` to use in the next request.
这篇关于限制使用Blogger API提取的帖子数量(错误400)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!