Tuesday, 25 August 2015

Validator API Research

Posting a document as the HTTP request. Looks like it can be done through JavaScript in the form of an AJAX call.

This method—POSTing a document as the HTTP entity body of a request—is the recommended way to use the checker as a Web service.

To use this method to check a document:
  • Issue an HTTP request with a URL for an existing checker instance such ashttps://validator.w3.org/nu/ or https://validator.nu/.
  • Use the POST method for the request.
  • Include the document to check as as the entity body of the request.
  • Include the Content-Type request header to communicate the MIME type of the entity body; e.g., Content-type: text/html; charset=utf-8.
  • Encode common parameters as query-string parameters; that is, just as you would with a GET request.

https://github.com/validator/validator/wiki/Service:-Input:-POST-body

The link below shows examples of POST requests using AJAX.

http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

Can get the Nu Validator to Output JSON objects.

Format is:
Type (The type of message / INFO / WARNING ect, Also where it occurs lines columns)
Subtype (Warning)
Message (The actual warning message to display / The semantics needed to fix the error)
Extract (Code snippet)

No comments:

Post a Comment