Bildirim hizmeti

AFP bildirim hizmeti, AFP şeffaf platformlarının PlatformChildSite onayları sonrasında bildirim almasına olanak tanır. Bu bildirim, sitenin artık API'de kullanılabildiğini gösterir.

Bildirim almak için POST isteklerini kabul eden ve şemada belirtilen JSON yükünü ayrıştıran bir sunucu uygulayın (örnek kuruluma bakın). Ardından, hizmeti etkinleştirmek için uç nokta URL'sini stratejik iş ortağı yöneticinize 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": {
    "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
}

Daha sonra daha fazla notificationTypes ve başka alanlar eklenebilir.

Örnekler

SITE_APPROVAL bildirimi şu şekilde görünür:

{
  "platformPublisherId" : "pub-123",
  "publisherId" : "pub-456",
  "platformChildSiteName" : "accounts/pub-123/platforms/my-platform/childAccounts/pub-456/sites/child-domain.com",
  "notificationType": "SITE_APPROVAL"
}

Örnek kurulum

Aşağıda, bildirimin içeriğini günlüğe kaydeden bir NodeJS sunucu ö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 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}`);
});

Örnek uç nokta URL'si: https://yourdomain.com/your-endpoint

curl kullanarak 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 '{"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 dosyasını yapılandırma

Bildirim hizmetinin uç noktanıza erişmesine izin verildiğini doğrulayın. Bildirim hizmeti, varsa alanınızın kökündeki robots.txt dosyasında belirtilen yönergelere uyar:

User-agent: GoogleOther
Disallow: <ensure your endpoint is not disallowed>