2015-09-27 233 views
0

我一直在想方法來使用Blogger API 3.0發佈json數據。我有一個關於GET方法的想法,所以我能碰到一個URL讀取JSON數據,但我有點困惑究竟如何,我可以做下面的請求JQuery-使用授權發佈Post請求

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#作爲編程語言控制檯應用程序來完成。

回答

0

要發送POST請求:

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); 
    } 
}) 
+0

我們如何通過'授權:/ *的OAuth 2.0令牌這裏* /'? –