I am passing credentials to an API I'm using, but I can't get a response. Here is the code I have tried:
<!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP script!";
$request = new HttpRequest();
$request->setUrl('https://api.mindbodyonline.com/public/v6/usertoken/issue');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'Content-Type' => 'application/json',
'SiteId' => '-99',
'Api-Key' => 'apikey12345'
));
$request->setBody('{
"Username": "myusername",
"Password": "mypassword"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
</body>
</html>
I see the echo "My first PHP script!" on my page, but I do not see the response. Nothing in the console. Am I doing something wrong?