Examples

Examples

Url

    https://api.moderatecontent.com/moderate/?
    key=[Your_Key]&
    url=https://www.moderatecontent.com/img/sample.png
    
jQuery

    $.ajax('https://api.moderatecontent.com/moderate/', {
        method: "GET",
        dataType: 'json',
        data: {
            key: '[Your_Key]',
            url: 'https://www.moderatecontent.com/img/sample.png'
        },
        success: function (response) {
            console.log(response);
        }
    });
    
iOS Swift

import Foundation

let headers = [
  "content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
  "cache-control": "no-cache"
]
let parameters = [
  [
    "name": "file",
    "fileName": "\images\test.png"
  ]
]

let boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.moderatecontent.com/moderate/?key=[Your_Key]")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
    
jQuery JSONP

    $.ajax('https://api.moderatecontent.com/moderate/', {
        method: "GET",
        jsonp: "callback",
        dataType: "jsonp",
        data: {
            key: '[Your_Key]',
            url: 'https://www.moderatecontent.com/img/sample.png'
        },
        success: function (response) {
            console.log(response);
        }
    });
    
Javascript

    var ajax_url = "https://api.moderatecontent.com/moderate/";
    var image_url = "https://www.moderatecontent.com/img/sample.png"; 
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            alert(xhttp.responseText);
        }
    };
    xhttp.open("GET", ajax_url + "?key=[Your_Key]&url=" + image_url, true);
    xhttp.send();