Last active
October 1, 2020 07:37
-
-
Save crashmax-dev/f86350b8a4b85311ac8676a906b973eb to your computer and use it in GitHub Desktop.
JSON Validator API - https://crashmax.ru/api/getJSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$headers = getallheaders(); | |
header("Content-Type: application/json"); | |
header("Access-Control-Allow-Credentials: true"); | |
header("Access-Control-Allow-Origin: ".$headers["Origin"]); | |
$data = $_POST["value"]; | |
if (isset($data) && !empty($data)) { | |
$ch = curl_init(); | |
$postfields = [ | |
"data" => $data, | |
"jsonspec" => 4, | |
"jsontemplate" => 2 | |
]; | |
curl_setopt($ch, CURLOPT_URL,"https://jsonformatter.curiousconcept.com/process"); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/x-www-form-urlencoded"]); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
echo $response; | |
} else { | |
echo json_encode( | |
[ | |
"result" => false, | |
"description" => "Bad Request!" | |
], JSON_PRETTY_PRINT); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment