plivo-php: Client Error Response while sending SMS

I get the following error while trying to make a POST request to send message:

Client error response [status code] 400 [reason phrase] BAD REQUEST [url] https://api.plivo.com/v1/Account/{AUTH ID}/Message/

When you look at the trace, there’s an exception being thrown by Guzzle. But there’s no way to know what may be wrong with the request being made by Plivo.

Any idea how to solve this?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 22

Most upvoted comments

You should use composer init in your project directory to make a new composer.json file for your project which then references the plivo/plivo-php package. See https://getcomposer.org/doc/01-basic-usage.md and https://getcomposer.org/doc/03-cli.md#init for more details

Hi , While writing sample send sms php script I am facing following error. Please help me to fix this.

Fatal error: Uncaught exception ‘GuzzleHttp\Exception\RequestException’ with message ‘cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)’ in C:\xampp\htdocs\public\mydomain_com\plivo\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 Stack trace: #0 C:\xampp\htdocs\public\mydomain_com\plivo\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\public\mydomain_com\plivo\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp\htdocs\public\mydomain_com\plivo\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(G in C:\xampp\htdocs\public\mydomain_com\plivo\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187

Below is my php script

`<?php require ‘vendor\autoload.php’; use Plivo\RestAPI; $auth_id = “VALID_AUTH_ID”; $auth_token = “VALID_AUTH_TOKEN”; $p = new RestAPI($auth_id, $auth_token);

// Set message parameters
$params = array(
    'src' => '19999999999', // Sender's phone number with country code
    'dst' => '18888888888', // Receiver's phone number with country code
    'text' => 'Hi, Message from Plivo', // Your SMS text message
    'url' => 'http://www.mydomain.com/plivo/send_sms_status.php', // The URL to which with the status of the message is sent
    'method' => 'POST' // The method used to call the url
);
// Send message
$response = $p->send_message($params);

// Print the response
$mid = $response['response']['message_uuid'][0];
error_log("SEND_SMS :: Message UUID :  $mid \n", 3, "C:\sms_log.txt");

?>`

my composer.json is

{ "name": "plivo/plivo-php", "description": "Plivo PHP helper library to access PlivoCloud API and generate Plivo XML", "authors": [ { "name": "Plivo Team", "email": "hello@plivo.com" }, { "name": "Ben McInturff", "email": "benmcinturff@gmail.com" }, { "name": "Adam Homsi", "email": "adam.homsi@gmail.com" }, { "name": "Radu Topala", "email": "radu.topala@trisoft.ro" } ], "license": "MIT", "require": { "guzzlehttp/guzzle": "~6.0" }, "autoload": { "classmap": ["plivo.php"] } }