JQuery-通过授权发布帖子请求

时间:2015-09-27 07:43:17

标签: c# jquery post blogger

我一直试图找出使用Blogger API 3.0发布json数据的方法。我对GET方法有一个想法,所以我能够读取一个读取json数据的url,但我对我如何能够提出以下请求感到有点困惑

Adding a post

You can add a post for a blog by sending a POST request to the post collection URI with a post JSON body:

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..."
}
You must be authenticated to create a post.

我试图使用Blogger API 3来创建新帖子。

参考:http://code.blogger.com/2012/06/blogger-api-v3.html

更新:如果使用C#作为编程语言使用控制台应用程序可以做同样的事情,我有点好奇。

1 个答案:

答案 0 :(得分:0)

发送帖子请求:

var post_data = {
   "kind": "blogger#post",
   "blog": {"id": "8070105920543249955"},
   "title": "A new post",
   "content": "With <b>exciting</b> content..."
}

$.ajax({
    type: 'POST',
    url: 'your_request_url_here',
    dataType: 'JSON',
    data: post_data,
    complete: function(res) {
       console.log(res);
    }
})