Posts:patch

需要授權

更新訊息。這個方法支援修補語意立即試用查看範例

要求

HTTP 要求

PATCH https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId

參數

參數名稱 說明
必要參數
blogId string 網誌的 ID。
postId string 貼文的 ID。

授權

此要求需要至少具備下列其中一個範圍的授權 (進一步瞭解驗證和授權)。

範圍
https://www.googleapis.com/auth/blogger

要求主體

在要求主體中提供貼文資源

回應

如果成功,此方法會在回應主體中傳回 Posts 資源

範例

注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面

Java

使用 Java 用戶端程式庫

// The BlogId of a test blog.
String TEST_BLOG_ID = "8070105920543249955";
// The PostId of a post.
String POST_ID = "4883581657838685651";
// Configure the Java API Client for Installed Native App
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
// Configure the Installed App OAuth2 flow.
Credential credential = OAuth2Native.authorize(HTTP_TRANSPORT,
JSON_FACTORY, new LocalServerReceiver(),
Arrays.asList(BloggerScopes.BLOGGER));
// Construct the Blogger API access facade object.
Blogger blogger = Blogger.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Blogger-PostsPatch-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// Construct the patch
Post patch = new Post();
patch.setId(Long.parseLong(POST_ID));
patch.setContent("With really <emph>exciting</emph> <code>HTML</code> content");
// The request action.
Patch postsPatchAction = blogger.posts().patch(TEST_BLOG_ID, POST_ID, patch);
// Restrict the result content to just the data we need.
postsPatchAction.setFields("author/displayName,content,published,title,url");
// This step sends the request to the server.
Post post = postsPatchAction.execute();
// Now we can navigate the response.
System.out.println("Title: " + post.getTitle());
System.out.println("Author: " + post.getAuthor().getDisplayName());
System.out.println("Published: " + post.getPublished());
System.out.println("URL: " + post.getUrl());
System.out.println("Content: " + post.getContent());

試試看!

使用 APIs Explorer 針對即時資料呼叫這個方法,並查看回應。