貼文:刪除

需要授權

依 ID 刪除訊息。立即試用查看範例

要求

HTTP 要求

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

參數

參數名稱 說明
必要參數
blogId string 網誌的 ID。
postId string 留言的 ID。
useTrash boolean 如果可以的話,請將其移至垃圾桶。請注意,只有即時貼文和已排定張貼時間的訊息可以移至垃圾桶。

授權

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

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

要求主體

請不要透過此方法提供請求主體。

回應

如果成功,此方法會傳回空白的回應主體。

範例

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

Java

使用 Java 用戶端程式庫

// The BlogId of a test blog.
String TEST_BLOG_ID = "8070105920543249955";
// The PostId of a post to delete
String POST_ID = "3445355871727114160";
// 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-PostsDelete-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
Delete postsDeleteAction = blogger.posts().delete(TEST_BLOG_ID, POST_ID);
// This step sends the request to the server.
try {
postsDeleteAction.execute();
System.out.println("Deleting post " + POST_ID + " succeeded.");
} catch (IOException e) {
System.out.println("Deleting post " + POST_ID + " failed: " + e);
}

試試看!

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