public function sendSMS(Request $request)
{
try {
$client = new \MessageBird\Client('key from env');
$message = new \MessageBird\Objects\Message();
$message->originator = 'MessageBird';
$message->recipients = '44750000000';
$message->body = 'This is a test message.';
$MessageResult = $client->messages->create(json_encode($Message));
/// var_dump($MessageResult);
return response()->json([
'success' => true,
'response' => json_encode($MessageResult)
]);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
echo 'wrong login';
} catch (\MessageBird\Exceptions\BalanceException $e) {
// That means that you are out of credits, so do something about it.
echo 'no balance';
} catch (\Exception $e) {
echo $e->getMessage();
}
}
But I keep seeing "Unauthenticated." and I'm not sure why. Can someone kindly help me out please.
By the way I have the CSRF except set also so this shouldn't interfere.
401 Unauthenticated Error [HELP]
Hi all,
Having a totally brain freeze here...I'm trying to post to the MessageBird API to send an SMS using Ajax.
And my controller looks like:
But I keep seeing
"Unauthenticated."
and I'm not sure why. Can someone kindly help me out please. By the way I have the CSRF except set also so this shouldn't interfere.