【发布时间】:2013-05-30 23:51:32
【问题描述】:
我想通过 PHP 添加一个post to a Blogger blog。 谷歌提供了下面的例子。如何在 PHP 中使用它?
您可以通过向帖子发送 POST 请求来为博客添加帖子 带有后 JSON 正文的集合 URI:
POST https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/
Authorization: /* OAuth 2.0 token here */
Content-Type: application/json
{
"kind": "blogger#post",
"blog": {
"id": "8070105920543249955"
},
"title": "A new post",
"content": "With <b>exciting</b> content..."
}
【问题讨论】:
-
我还建议您对内容使用 JSON,因为您可以创建一个类或函数,该类或函数将返回一个您可以使用 json_encode 序列化的对象。您可以在此处找到有关该主题的更多信息:php.net/manual/de/ref.json.php - 这只是对该主题的附加建议 :-)
-
stream_context_createhttpcontent字段包含请求的 http 正文。添加此评论 b/c 这未在答案中明确说明。