ดึงทรัพยากรหน้าเว็บ 1 รายการด้วยรหัสหน้าเว็บ ลองใช้เลยหรือดูตัวอย่าง
ต้องมีการให้สิทธิ์ หากหน้าเว็บอยู่บนบล็อกที่เป็นส่วนตัว หากหน้าเว็บนี้อยู่ในบล็อกสาธารณะ จะสามารถเรียกใช้วิธีนี้ได้โดยไม่ต้องขออนุญาต
ส่งคำขอ
คำขอ HTTP
GET https://www.googleapis.com/blogger/v3/blogs/blogId/pages/pageId
พารามิเตอร์
ชื่อพารามิเตอร์ | ค่า | คำอธิบาย |
---|---|---|
พารามิเตอร์ที่จําเป็น | ||
blogId |
string |
รหัสของบล็อกที่มีหน้านี้ |
pageId |
string |
รหัสของหน้าเพื่อรับ |
พารามิเตอร์ที่ไม่บังคับ | ||
view |
string |
ค่าที่ยอมรับมีดังนี้
|
เนื้อหาของคำขอ
อย่าให้เนื้อหาคําขอด้วยวิธีนี้
คำตอบ
หากสําเร็จวิธีนี้จะแสดงทรัพยากรของหน้าเว็บในส่วนเนื้อหาของการตอบกลับ
ตัวอย่าง
หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)
Java
// The BlogId for the http://buzz.blogger.com/ blog.
String BUZZ_BLOG_ID = "2399953";
// The PageId for a buzz page.
String BUZZ_PAGE_ID = "8251768148820290538";
// 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-PagesGet-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
Get pagesGetAction = blogger.pages().get(BUZZ_BLOG_ID, BUZZ_PAGE_ID);
// Restrict the result content to just the data we need.
pagesGetAction.setFields("content,published,updated,title,url");
// This step sends the request to the server.
Page page = pagesGetAction.execute();
// Now we can navigate the response.
System.out.println("Title: " + page.getTitle());
System.out.println("Publised: " + page.getPublished());
System.out.println("Updated: " + page.getUpdated());
System.out.println("URL: " + page.getUrl());
System.out.println("Content: " + page.getContent());
ลองใช้เลย
ใช้เครื่องมือสํารวจ API ด้านล่างเพื่อเรียกใช้วิธีการนี้สําหรับข้อมูลสดและดูการตอบกลับ