Ich versuche, SMS mit meiner Laravel-Anwendung zu senden. Ich habe infobip Konto Tests und die Verwendung dieser Details zu SMS SMS aber immer diese Fehlermeldung:Infobip einzigen SMS-Dienst mit guzzle in Laravel
ClientException in RequestException.php line 111:
Client error: `POST https://api.infobip.com/sms/1/text/single` resulted in a `401 Unauthorized` response:
{"requestError":{"serviceException": {"messageId":"UNAUTHORIZED","text":"Invalid login details"}}}
Code:
$data= '{
"from":"InfoSMS",
"to":"923227124444",
"text":"Test SMS."
}';
$userstring = 'myuserame:password';
$id =base64_encode ('myuserame:password');
echo 'Basic '.$id;
$client = new \GuzzleHttp\Client();
$request = $client->post('https://api.infobip.com/sms/1/text/single',array(
'content-type' => 'application/json'
),['auth' => ['myusername', 'password']]);
$request->setHeaders(array(
'accept' => 'application/json',
'authorization' => 'Basic '.$id,
'content-type' => 'application/json'
));
$request->setBody($data); #set body!
$response = $request->send();
echo $res->getStatusCode(); // 200
echo $res->getBody();
return $response;
Der Benutzername und das pssword recht, wie ich versuchte, von der direkten Textnachricht senden die Website und ihre Arbeit dort.
Kann mir jemand helfen, was mache ich falsch?
Danke!
Ich bekam Request Fehler in diesem aber ich müde, es mit Locken zu lösen. Code hier platzieren. –