सूचना सेवा
एएफ़पी सूचना सेवा की मदद से, एएफ़पी डायरेक्ट प्लैटफ़ॉर्म को सब-खाते और साइट की स्थिति में होने वाले बदलावों के बारे में सूचनाएं मिलती हैं. प्लैटफ़ॉर्म, बदलावों की जांच करने के लिए Platform API का इस्तेमाल कर सकते हैं.
सूचनाएं पाने के लिए, ऐसा सर्वर लागू करें जो POST अनुरोध स्वीकार करता हो और स्कीमा में बताए गए JSON पेलोड को पार्स करता हो. सेटअप का उदाहरण देखें. इसके बाद, आपको सेवा चालू करने के लिए, अपने स्ट्रेटेजिक पार्टनर मैनेजर को एंडपॉइंट यूआरएल देना होगा.
स्कीमा
सूचना पेलोड, इस स्कीमा के मुताबिक होना चाहिए:
{
"$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}`);
});
एंडपॉइंट यूआरएल का उदाहरण: 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
फ़ाइल में बताए गए निर्देशों का पालन करती है. हालांकि, ऐसा तब ही होता है, जब robots.txt
फ़ाइल मौजूद हो:
User-agent: GoogleOther
Disallow: <ensure your endpoint is not disallowed>