Skip to content

Instantly share code, notes, and snippets.

@cupertinobr
Last active November 1, 2023 17:59
Show Gist options
  • Save cupertinobr/82258531f9db4480ee39f1b0ce5401dd to your computer and use it in GitHub Desktop.
Save cupertinobr/82258531f9db4480ee39f1b0ce5401dd to your computer and use it in GitHub Desktop.
ScriptCaseRESTService
/*
Crie uma app blank: RESTService
- no onExecute insira os códigos abaixo
- Crie os metodos, no meu exemplo eu criei um metodo chamado checkLicense() quere recebe a variavel $body
- a variavel $boby recebe o input (os dados que vai enviar em formato json)
*/
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Allow-Credentials: true");
header("Content-Type: application/json");
$body = file_get_contents("php://input");
$query = $_SERVER['QUERY_STRING'];
$method = strtoupper($_SERVER['REQUEST_METHOD']);
switch( $method )
{
case 'GET':
break;
case 'POST':
checkLicense($body);
break;
case 'PUT':
break;
case 'DELETE':
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment