โพสต์: แพตช์

ต้องมีการให้สิทธิ์

อัปเดตโพสต์ วิธีการนี้รองรับความหมายแพตช์ ลองใช้เลยหรือดูตัวอย่าง

ส่งคำขอ

คำขอ HTTP

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

พารามิเตอร์

ชื่อพารามิเตอร์ ค่า คำอธิบาย
พารามิเตอร์ที่จําเป็น
blogId string รหัสของบล็อก
postId string รหัสของโพสต์

การให้สิทธิ์

คําขอนี้ต้องมีการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 ขอบเขต (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)

ขอบเขต
https://www.googleapis.com/auth/blogger

เนื้อหาของคำขอ

ในเนื้อหาคําขอ ให้ระบุแหล่งข้อมูลโพสต์

คำตอบ

หากสําเร็จวิธีนี้จะแสดงทรัพยากรโพสต์ในส่วนเนื้อหาของการตอบกลับ

ตัวอย่าง

หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)

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());

ลองใช้เลย

ใช้เครื่องมือสํารวจ API ด้านล่างเพื่อเรียกใช้วิธีการนี้สําหรับข้อมูลสดและดูการตอบกลับ