알림 서비스
AFP 알림 서비스를 사용하면 AFP 투명 플랫폼이 PlatformChildSite 승인 시 알림을 수신하여 이제 API에서 사이트를 사용할 수 있음을 알릴 수 있습니다.
알림을 수신하려면 POST 요청을 수락하고 스키마에 설명된 JSON 페이로드를 파싱하는 서버를 구현합니다(설정 예 참고). 그런 다음 전략적 파트너 관리자에게 엔드포인트 URL을 제공하여 서비스를 활성화해야 합니다.
스키마
알림 페이로드는 다음 스키마를 준수해야 합니다.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Notification",
"type": "object",
"properties": {
"platformPublisherId": {
"type": "string",
"description": "The unique identifier for the platform publisher."
},
"publisherId": {
"type": "string",
"description": "The unique identifier for the publisher."
},
"platformChildSiteName": {
"type": "string",
"description": "The name of the PlatformChildSite the notification refers to (populated for SITE_APPROVAL)."
},
"notificationType": {
"type": "string",
"enum": ["SITE_APPROVAL"],
"description": "Type of notification"
},
},
"required": ["platformPublisherId", "publisherId", "notificationType"],
"additionalProperties": false
}
나중에 더 많은 notificationTypes
및 기타 필드를 추가할 수 있습니다.
예
SITE_APPROVAL
알림은 다음과 같습니다.
{
"platformPublisherId" : "pub-123",
"publisherId" : "pub-456",
"platformChildSiteName" : "accounts/pub-123/platforms/my-platform/childAccounts/pub-456/sites/child-domain.com",
"notificationType": "SITE_APPROVAL"
}
설정 예시
다음은 알림의 콘텐츠를 로깅하는 NodeJS 서버의 예입니다.
// Import express
const express = require('express');
// Create an express application
const app = express();
// Middleware to parse JSON bodies
app.use(express.json());
// Define a route to receive POST requests
app.post('/notification', (req, res) => {
console.log('Received platformPublisherId:', req.body.platformPublisherId)
console.log('Received publisherId:', req.body.publisherId)
console.log('Received platformChildSiteName:', req.body.platformChildSiteName)
console.log('Received notification type', req.body.notificationType)
// Send a response back to the client
res.status(200).send('Notification received');
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
엔드포인트 URL 예: https://yourdomain.com/your-endpoint
curl
를 사용하여 POST 요청을 전송하여 엔드포인트가 작동하는지 확인합니다.
curl -X POST https://yourdomain.com/your-endpoint \
-H "Content-Type: application/json" \
-d '{"platformPublisherId" : "pub-123", \
"publisherId" : "pub-456", \
"platformChildSiteName" : "accounts/pub-123/platforms/my-platform/childAccounts/pub-456/sites/child-domain.com", \
"notificationType": "SITE_APPROVAL"}'
robots.txt 구성
알림 서비스에 엔드포인트에 대한 액세스가 허용되는지 확인합니다. 알림 서비스는 도메인 루트의 robots.txt
파일(있는 경우)에 설명된 지시를 따릅니다.
User-agent: GoogleOther
Disallow: <ensure your endpoint is not disallowed>