বিজ্ঞপ্তি পরিষেবা
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>