貼文:刪除

需要授權

依 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);
}

試試看!

您可以使用下方的 API Explorer,針對即時資料呼叫這個方法,然後查看回應。