บล็อก: listByUser

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

เรียกรายชื่อบล็อก ลองเลยหรือดูตัวอย่าง

ส่งคำขอ

คำขอ HTTP

GET https://www.googleapis.com/blogger/v3/users/userId/blogs

พารามิเตอร์

ชื่อพารามิเตอร์ ค่า คำอธิบาย
พารามิเตอร์ที่จำเป็น
userId string รหัสของผู้ใช้ที่มีบล็อกที่จะดึงข้อมูล อาจเป็นคำว่า self หรือรหัสโปรไฟล์ของผู้ใช้
พารามิเตอร์ที่ไม่บังคับ
fetchUserInfo boolean ระบุว่าคำตอบเป็นรายการบล็อกที่มีข้อมูลสำหรับผู้ใช้แต่ละรายหรือไม่ แทนที่จะแสดงเฉพาะบล็อก
view string

ค่าที่ยอมรับได้ มีดังนี้
  • "ADMIN": รายละเอียดระดับผู้ดูแลระบบ
  • "AUTHOR": รายละเอียดระดับผู้เขียน
  • "READER": รายละเอียดระดับผู้ดูแลระบบ

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

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

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

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

โปรดอย่าให้เนื้อหาคำขอตามวิธีการนี้

คำตอบ

หากสำเร็จ เมธอดนี้จะแสดงเนื้อหาการตอบกลับซึ่งมีโครงสร้างต่อไปนี้

{
  "kind": "blogger#blogList",
  "items": [
    blogs Resource
  ],
  "blogUserInfos": [
    blogUserInfos Resource
  ]
}
ชื่อพร็อพเพอร์ตี้ ค่า คำอธิบาย Notes
kind string ประเภทของเอนทิตีนี้ blogger#blogList เสมอ
items[] list รายการบล็อกที่ผู้ใช้รายนี้มีสิทธิ์ในการเป็นผู้เขียนหรือผู้ดูแลระบบ
blogUserInfos[] list รายการข้อมูลบล็อกสำหรับผู้ใช้แต่ละรายในระดับผู้ดูแลระบบ

ตัวอย่าง

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

Java

ใช้ไลบรารีของไคลเอ็นต์ Java

// 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-BlogListByUser-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action object.
ListByUser blogListByUserAction = blogger.blogs().listByUser("self");
// Restrict the result content to just the data we need.
blogListByUserAction.setFields("items(description,name,posts/totalItems,updated)");
// This step sends the request to the server.
BlogList blogList = blogListByUserAction.execute();
// Now we can navigate the response.
if (blogList.getItems() != null && !blogList.getItems().isEmpty()) {
int blogCount = 0;
for (Blog blog : blogList.getItems()) {
System.out.println("Blog #" + ++blogCount);
System.out.println("\tName: " + blog.getName());
System.out.println("\tDescription: " + blog.getDescription());
System.out.println("\tPost Count: " + blog.getPosts().getTotalItems());
System.out.println("\tLast Updated: " + blog.getUpdated());
}
}

ลองใช้เลย

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