सूचना सेवा

AFP सूचना सेवा की मदद से, AFP डायरेक्ट प्लैटफ़ॉर्म को उप-खाते और साइट की स्थिति में बदलाव होने पर सूचनाएं मिलती हैं. बदलावों की जांच करने के लिए, प्लैटफ़ॉर्म Platform API का इस्तेमाल कर सकते हैं.

सूचनाएं पाने के लिए, ऐसा सर्वर लागू करें जो पोस्ट अनुरोध स्वीकार करता हो और स्कीमा में बताए गए 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 का इस्तेमाल करके पोस्ट अनुरोध भेजकर पुष्टि करें कि आपका एंडपॉइंट काम कर रहा है:

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>