GetReader
GetReader
ช่วยให้ผู้เผยแพร่โฆษณาตรวจสอบได้ว่าผู้อ่านรายใดรายหนึ่งที่มี PPID ที่รู้จักได้ลิงก์การสมัครใช้บริการกับ Google หรือไม่ เมื่อใช้คําขอ GET
ผู้เผยแพร่โฆษณาจะค้นหา PPID ของรหัสการเผยแพร่ที่เฉพาะเจาะจง
ส่งคำขอ
REST API: คำขอ GET
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid
ไลบรารีของไคลเอ็นต์ (Node.js)
async function getReader(ppid) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.get({
name: `publications/${publicationId}/readers/${ppid}`,
});
};
การตอบกลับ
ปลายทางจะแสดงผลเป็น 200 พร้อมเนื้อหา JSON ที่มี created_time
ของการสมัครใช้บริการที่ลิงก์ หรือแสดงข้อผิดพลาดหากไม่พบ PPID ของสิ่งพิมพ์ ดูข้อมูลเพิ่มเติมได้ในส่วนข้อผิดพลาด
{
"name": "publications/CAowqfCKCw/readers/22553",
"createTime": "2025-07-30T18:26:58.050224Z",
"publicationId": "CAowqfCKCw",
"ppid": "22553",
"originatingPublicationId": "CAowqfCKCw"
}
GetReaderEntitlements
GetReaderEntitlements
ช่วยให้ผู้เผยแพร่โฆษณาค้นหาการให้สิทธิ์สำหรับ PPID ที่ระบุไว้ก่อนหน้านี้ได้ ผู้เผยแพร่โฆษณาใช้คําขอ GET เพื่อขอสิทธิ์โดยระบุ PPID และรหัสการเผยแพร่
ส่งคำขอ
REST API: คำขอ GET
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid/entitlements
ไลบรารีของไคลเอ็นต์ (Node.js)
async function getReaderEntitlements(ppid) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.getEntitlements({
name: `publications/${publicationId}/readers/${ppid}/entitlements`
});
};
การตอบกลับ
สำหรับคำขอที่สำเร็จ รูปแบบผลลัพธ์จะเหมือนกับรูปแบบที่ใช้เพื่อจัดเก็บการให้สิทธิ์ด้วยคำขอ UpdateReaderEntitlements
PATCH
{
"name": "publications/dailybugle.com/readers/6789/entitlements",
"entitlements": [
{
"product_id": "dailybugle.com:basic",
"subscription_token": "dnabhdufbwinkjanvejskenfw",
"detail": "This is our basic plan",
"expire_time": "2022-08-19T04:53:40+00:00"
},
{
"product_id": "dailybugle.com:premium",
"subscription_token": "wfwhddgdgnkhngfw",
"detail": "This is our premium plan",
"expire_time": "2022-07-19T04:53:40+00:00"
},
{
"product_id": "dailybugle.com:deluxe",
"subscription_token": "fefcbwinkjanvejfefw",
"detail": "This is our deluxe plan",
"expire_time": "2022-08-20T04:53:40+00:00"
}
]
}
สําหรับผู้ใช้ที่ไม่มีการให้สิทธิ์ แต่มี PPID ที่ลิงก์ (เช่น การให้สิทธิ์ที่หมดอายุและถูกลบออกแล้ว) คําขอการให้สิทธิ์จะแสดงผลอาร์เรย์การให้สิทธิ์ว่างเปล่าเป็นส่วนหนึ่งของออบเจ็กต์การให้สิทธิ์มาตรฐาน
{
"name": "publications/dailybugle.com/readers/6789/entitlements"
}
UpdateReaderEntitlements
UpdateReaderEntitlements
ใช้สำหรับสร้างและอัปเดตการให้สิทธิ์แก่ผู้อ่านตาม PPID ของผู้อ่าน
ตัวอย่างเพย์โหลดนี้ให้สิทธิ์ผู้อ่านที่มี PPID 6789
เข้าถึงรหัสผลิตภัณฑ์ 3 รายการของ The Daily Bugle ซึ่งได้แก่ dailybugle.com:basic
, dailybugle.com:premium
และ dailybugle.com:deluxe
เมื่อผู้อ่าน 6789
ใช้แพลตฟอร์มของ Google สําหรับ Search และ Discover ในภายหลัง รายการ "จากการติดตามของคุณ" จะแสดงผลการค้นหาที่เกี่ยวข้องจากบทความใน dailybugle.com ที่ติดแท็กรหัสผลิตภัณฑ์เหล่านี้
ส่งคำขอ
REST API: คำขอ PATCH
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid/entitlements
เนื้อหาคําขอ: ดูข้อมูลเพิ่มเติมเกี่ยวกับออบเจ็กต์ entitlements
ได้ในหน้าอภิธานศัพท์
{
entitlements : [{
product_id: `${publicationId}:basic`,
subscription_token: 'abc1234',
detail: 'This is our basic plan',
expire_time: '2025-10-21T03:05:08.200564Z'
}]
}
ไลบรารีของไคลเอ็นต์ (Node.js)
async function updateReaderEntitlements(ppid) {
const publicationId = process.env.PUBLICATION_ID;
const requestBody = {
entitlements : [{
product_id: `${publicationId}:basic`,
subscription_token: 'abc1234',
detail: 'This is our basic plan',
expire_time: '2025-10-21T03:05:08.200564Z'
}]
};
return await client.publications.readers.updateEntitlements({
name: `publications/${publicationId}/readers/${ppid}/entitlements`,
requestBody
});
};
การตอบกลับ
เมื่อการดำเนินการ PATCH สำเร็จ ระบบจะแสดงผลออบเจ็กต์ entitlements
ที่บันทึกไว้ในรูปแบบเดียวกับ GetReaderEntitlements
DeleteReader
DeleteReader
อนุญาตให้ผู้เผยแพร่โฆษณาลบการสมัครใช้บริการที่ลิงก์ด้วยตนเองได้
เมื่อใช้คำขอ DELETE
ผู้เผยแพร่โฆษณาจะส่ง PPID สำหรับรหัสการเผยแพร่ที่จะลบ
ก่อนเรียกใช้ DeleteReader
คุณต้องลบการให้สิทธิ์ก่อนโดยใช้ UpdateReaderEntitlements
ที่มีอาร์เรย์ว่าง ({ "entitlements": [] }
) หรือตั้งค่าพารามิเตอร์ force
(ไม่บังคับ) เป็น true
หากต้องการลบผู้อ่านที่มีการให้สิทธิ์
พารามิเตอร์ force
จะมีค่าเริ่มต้นเป็น false
ส่งคำขอ
REST API: คำขอ DELETE
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid?force={boolean}
ไลบรารีของไคลเอ็นต์ (Node.js)
async function deleteReader(ppid, forceDelete = false) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.delete({
name: `publications/${publicationId}/readers/${ppid}`
force: forceDelete
});
};
การตอบกลับ
การลบที่สำเร็จจะแสดงผลรหัส 200 พร้อมออบเจ็กต์ JSON ว่าง {}
{}