Comment rules

    List all comment rules

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/commentrules
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response body

    An array of the first 10 items; each object has the following properties:

    • objectType (integer)
      • 1 - WebPages
      • 7 - Announcements
      • 9 - Faq
      • 26 - Catalogue
      • 27 - Product
      • 35 - Webapp
      • 56 - Blog
    • siteId (integer)
    • moderateNewComments (boolean)
    • roleToNotify - must belong to an existing role or -1 for null (integer)
    • whoCanComment (integer)
      • 0 - Anyone can comment
      • 1 - Must be logged in - can comment unlimited
      • 2 - Must be logged in - can comment once only
    • automaticSpamDetection - must belong to an existing customer (boolean)
    • autoDeleteSpam (boolean)

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/commentrules",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    });
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    });

    Sample response

    {
      "items": [
        {
          "objectType": 1,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        },
        {
          "objectType": 7,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        },
        {
          "objectType": 9,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        },
        {
          "objectType": 26,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        },
        {
          "objectType": 27,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        },
        {
          "objectType": 35,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        },
        {
          "objectType": 56,
          "siteId": 38592,
          "moderateNewComments": true,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": true,
          "autoDeleteSpam": true
        }
      ],
      "totalItemsCount": 7,
      "skip": 0,
      "limit": 10
    }

    Get details of comment rule

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/commentrules/[objectType_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    • objectType (integer)
      • 1 - WebPages
      • 7 - Announcements
      • 9 - Faq
      • 26 - Catalogue
      • 27 - Product
      • 35 - Webapp
      • 56 - Blog
    • siteId (integer)
    • moderateNewComments (boolean)
    • roleToNotify - must belong to an existing role or -1 for null (integer)
    • whoCanComment (integer)
      • 0 - Anyone can comment
      • 1 - Must be logged in - can comment unlimited
      • 2 - Must be logged in - can comment once only
    • automaticSpamDetection - must belong to an existing customer (boolean)
    • autoDeleteSpam (boolean)

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/commentrule/1",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Sample response

    {
      "objectType": 1,
      "siteId": 38592,
      "moderateNewComments": true,
      "roleToNotify": -1,
      "whoCanComment": 0,
      "automaticSpamDetection": true,
      "autoDeleteSpam": true
    }

    Update a comment rule

    Request

    • Method: PUT
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/commentrules/[objectType_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • objectType (integer)
      • 1 - WebPages
      • 7 - Announcements
      • 9 - Faq
      • 26 - Catalogue
      • 27 - Product
      • 35 - Webapp
      • 56 - Blog
    • siteId (integer)
    • moderateNewComments (boolean)
    • roleToNotify - must belong to an existing role or -1 for null (integer)
    • whoCanComment (integer)
      • 0 - Anyone can comment
      • 1 - Must be logged in - can comment unlimited
      • 2 - Must be logged in - can comment once only
    • automaticSpamDetection - must belong to an existing customer (boolean)
    • autoDeleteSpam (boolean)

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/comments/1",
        type: "PUT",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        data: JSON.stringify({
          "moderateNewComments": false,
          "roleToNotify": -1,
          "whoCanComment": 0,
          "automaticSpamDetection": false,
          "autoDeleteSpam": false
        })
        
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })
      

    Response

    Returns an empty body if successful or a detailed error message.

    204 OK

    Accepts and returns JSON as Content-Type.