Bildirim hizmeti
AFP bildirim hizmeti, AFP Direct platformlarının alt hesap ve site durumu değişiklikleriyle ilgili bildirim almasına olanak tanır. Platformlar, değişiklikleri incelemek için Platform API'sini kullanabilir.
Bildirim almak için POST isteklerini kabul eden ve şemada özetlenen JSON yükünü ayrıştıran bir sunucu uygulayın (örnek kurulum bölümüne bakın). Ardından hizmeti etkinleştirmek için Stratejik İş Ortağı Yöneticinize uç nokta URL'sini sağlamanız gerekir.
Şema
Bildirim yükü aşağıdaki şemaya uygun olmalıdır:
{
"$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
}
İleride daha fazla notificationTypes
alanı ve başka alanlar eklenebilir.
Örnekler
Yayıncı onay bildirimi şu şekilde görünür:
{
"accountName" : "platforms/pub-1234567890123456/accounts/pub-0987654321654321",
"notificationType": "PUBLISHER_APPROVAL"
}
Bir site onay bildirimi şu şekilde görünür:
{
"accountName" : "platforms/pub-1234567890123456/accounts/pub-0987654321654321",
"domain": "afpsite.com",
"notificationType": "SITE_APPROVAL"
}
Örnek kurulum
Aşağıda, bir bildirimin içeriğini günlüğe kaydeden bir NodeJS sunucusu örneği verilmiştir:
// 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}`);
});
Örnek uç nokta URL'si: https://yourdomain.com/your-endpoint
curl
ile bir POST isteği göndererek uç noktanızın çalıştığını doğrulayın:
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 dosyasını yapılandırma
Bildirim hizmetinin uç noktanıza erişmesine izin verildiğinden emin olun. Bildirim hizmeti, varsa alanınızın kök klasörünün robots.txt
dosyasında ana hatları verilen yönergelere uyar:
User-agent: GoogleOther
Disallow: <ensure your endpoint is not disallowed>