알림 서비스
AFP 알림 서비스를 사용하면 AFP Direct 플랫폼에서 하위 계정 및 사이트 상태가 변경될 때 알림을 수신할 수 있습니다. 플랫폼은 Platform API를 사용하여 변경사항을 조사할 수 있습니다.
알림을 수신하려면 POST 요청을 수락하고 스키마에 설명된 JSON 페이로드를 파싱하는 서버를 구현합니다 (설정 예 참고). 그런 다음 전략적 파트너 관리자에게 엔드포인트 URL을 제공하여 서비스를 활성화해야 합니다.
스키마
알림 페이로드는 다음 스키마를 준수해야 합니다.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Notification",
"type": "object",
"properties": {
"accountName": {
"type": "string",
"description": "The name of the modified sub-account."
},
"domain": {
"type": "string",
"description": "The domain the notification refers to, if any. Optional (only populated for SITE_APPROVAL)"
},
"notificationType": {
"type": "string",
"enum": ["PUBLISHER_APPROVAL", "SITE_APPROVAL"],
"description": "Type of notification"
}
},
"required": ["platformPublisherId", "publisherId", "notificationType"],
"additionalProperties": false
}
나중에 더 많은 notificationTypes
및 기타 필드를 추가할 수 있습니다.
예
게시자 승인 알림은 다음과 같습니다.
{
"accountName" : "platforms/pub-1234567890123456/accounts/pub-0987654321654321",
"notificationType": "PUBLISHER_APPROVAL"
}
사이트 승인 알림은 다음과 같이 표시됩니다.
{
"accountName" : "platforms/pub-1234567890123456/accounts/pub-0987654321654321",
"domain": "afpsite.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 account name:', req.body.accountName)
console.log('Received Domain:', req.body.domain)
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 '{"accountName": "platforms/pub-1234567890123456/accounts/pub-0987654321654321", \
"notificationType": "PUBLISHER_APPROVAL"}'
robots.txt 구성
알림 서비스에 엔드포인트에 대한 액세스가 허용되어 있는지 확인합니다. 알림 서비스는 도메인 루트의 robots.txt
파일(있는 경우)에 설명된 지시를 따릅니다.
User-agent: GoogleOther
Disallow: <ensure your endpoint is not disallowed>