Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. ClientException in RequestException.php line 111:
  2. Client error: `POST https://api.infobip.com/sms/1/text/single` resulted in a `401 Unauthorized` response:
  3. {"requestError":{"serviceException": {"messageId":"UNAUTHORIZED","text":"Invalid login details"}}}
  4.  
  5. $data= '{
  6. "from":"InfoSMS",
  7. "to":"923227124444",
  8. "text":"Test SMS."
  9. }';
  10. $userstring = 'myuserame:password';
  11. $id =base64_encode ( 'myuserame:password' );
  12. echo 'Basic '.$id;
  13. $client = new GuzzleHttpClient();
  14. $request = $client->post('https://api.infobip.com/sms/1/text/single',array(
  15. 'content-type' => 'application/json'
  16. ),['auth' => ['myusername', 'password']]);
  17. $request->setHeaders(array(
  18. 'accept' => 'application/json',
  19.  
  20. 'authorization' => 'Basic '.$id,
  21. 'content-type' => 'application/json'
  22. ));
  23. $request->setBody($data); #set body!
  24. $response = $request->send();
  25. echo $res->getStatusCode(); // 200
  26. echo $res->getBody();
  27. return $response;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement