PHP code example of pagemill / accept
1. Go to this page and download the library: Download pagemill/accept library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pagemill / accept example snippets
// content types with which the web service can respond
$valid_content_types = [
"application/json",
"text/xml"
];
$accept = new \PageMill\Accept\Accept();
$content_type = $accept->determine($valid_content_types);
// If Accept did not find an acceptable content type, the determine method
// will return null. The server should respond to the client with a 406.
if ($content_type === null) {
// Respond with 406 Not Acceptable
http_response_code(406);
exit();
}