Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Error Response while sending SMS #20

Closed
manthan787 opened this issue Sep 23, 2015 · 22 comments
Closed

Client Error Response while sending SMS #20

manthan787 opened this issue Sep 23, 2015 · 22 comments

Comments

@manthan787
Copy link

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?

@cachrisman
Copy link

@manthan787 Are you still having this issue? We just released a new version of the library to support the newest version of guzzle. Hopefully that fixed this problem.

@manthan787
Copy link
Author

@cachrisman Yes it's working perfectly now!

@dbelieves
Copy link

Hi, i am not able to send an sms i get the following error:

HTTP/1.1 400 BAD REQUEST
Content-Type: application/json
Date: Wed, 02 Dec 2015 16:41:59 GMT
Server: nginx/1.6.2
X-Plivo-Signature: 7VTk7wira5OfTDfbKbs7yxEyzbo=
Content-Length: 103
Connection: keep-alive
{
"api_id": "9a7f2d78-9913-11e5-bd65-22000ae3016b",
"error": "invalid json data sent in raw POST"
}

I am using CURL.

@cachrisman
Copy link

@dbelieves are you using the latest version of the plivo-php helper library? please share the code you use to send sms.

@dbelieves
Copy link

@cachrisman, its resolved.
had smart quotes in query.

@Amarja
Copy link

Amarja commented Dec 17, 2015

I update composer and install new plivo as well as guzzle but, now I am getting error as,

"Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain..."

Before updating composer.json it works very well. So how to solve this problem?

@cachrisman
Copy link

@Amarja can you post your composer.json and the code where you use a Plivo function which causes this error?

@Amarja
Copy link

Amarja commented Dec 18, 2015

@cachrisman thanks for your reply.

My composer.json looks like,
{
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"illuminate/html": "^5.0",
"plivo/plivo-php": "~1.1.0"
},
}
In my plivo folder's composer.json,
"require": {
"guzzlehttp/guzzle": "v6.1.1"
},

and my Plivo folder is in the root folder. I have used plivo functionality into simple php file.

'141548XXXXX', 'dst' => '91XXXXXXXXXX', 'text' => 'Hi, I am Amarja :)', 'url' => 'http://localhost/untitled/sentsms.php', 'method' => 'POST' ); // Send message $response = $p->send_message($params); echo "Response : "; print_r ($response['response']); echo"error code is:".curl_easy_strerror(); echo "
Api ID : {$response['response']['api_id']}
"; echo "Message UUID : {$response['response']['message_uuid'][0]}
"; ?>

@cachrisman
Copy link

@Amarja you have to have a publicly available url set as the url parameter. That is telling Plivo to post the message details to that url but Plivo can't access your localhost. Try ngrok

@Amarja
Copy link

Amarja commented Dec 18, 2015

@cachrisman I tried after changing url, still having same issue....But before updating composer.json it works well and I'm getting this problems after updating the updating composer.json. Is there any other package that I am not updating?

@cachrisman
Copy link

@Amarja can you make a fresh project (make a new directory and do a composer init and choose the plivo-php package and then do composer install) and copy in your php file and see if that works?

@Amarja
Copy link

Amarja commented Dec 21, 2015

@cachrisman Thanks so much for your reply, I will try this..

@ariyawansha81
Copy link

i got the following error when use the latest plivo.php.

Parse error: syntax error, unexpected '[', expecting ')' in /home15/clientke/public_html/smst2/plivo.php on line 41

following is my test sending php file

'Company name', // Sender's phone number with country code 'dst' => '61490xxxx', // Receiver's phone number with country code 'text' => 'Hi, Message from Plivo', // Your SMS text message 'url' => 'https://glacial-harbor-8656.herokuapp.com/report', // The URL to which with the status of the message is sent 'method' => 'POST' // The method used to call the url //'text' => 'こんにちは、元気ですか?' # Your SMS Text Message - Japanese //'text' => 'Ce est texte généré aléatoirement' # Your SMS Text Message - French ); // Send message $response = $p->send_message($params); // Print the response echo "Response : "; print_r($response['response']); // Print the Api ID echo "
Api ID : {$response['response']['api_id']}
"; // Print the Message UUID echo "Message UUID : {$response['response']['message_uuid'][0]}
"; ``` ?>

@Amarja
Copy link

Amarja commented Feb 24, 2016

I want to send a sms using custom from variable. For that I made it as 'src' => 'custom name', then I checked at plivo's account site here in the sms logs it shows me 'custom name' as source, but when actual sms was sent to the mobile then it shows 'VM-PLVSMS' as a source/from on the mobile. I want to change it to the custome one. Any idea how can I change it? Thanks in advance.

@Ramya-Raghu
Copy link

@Amarja you will have to register the custom alpha-numeric sender id with the carrier. Please write to support@plivo.com with the details and we'll register it for you.

@Amarja
Copy link

Amarja commented Feb 24, 2016

@Ramya-Raghu thanks for your quick reply. I will go through it.

@npatkar
Copy link

npatkar commented Mar 27, 2016

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"] } }

@cachrisman
Copy link

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

@Amarja
Copy link

Amarja commented May 11, 2016

Generally when we get OTP from any site then usually it is in the specific format. I am using plivo but I don't know how to insert that OTP with specific format. Here is my code,

// Set message parameters
$params = array(
'src' => '19999999999', // Sender's phone number with country code
'dst' => '18888888888', // Receiver's phone number with country code
'text' => 'OTP is '.$otp.'.' , // I want this OTP number in appropriate format
'url' => 'http://www.mydomain.com/ // The URL to which with the status of the message is sent
'method' => 'POST' // The method used to call the url
);

Please give any suggestions, Thanks a lot in advance.

@cachrisman
Copy link

@Amarja that code will work provided src is a valid Number in your account. Is that not working?

@Amarja
Copy link

Amarja commented May 12, 2016

@cachrisman Thanks, now it's working properly :)

@Andre-Sekou
Copy link

Hi everyone!
I have the same issue like npatkar commented on 27 Mar 2016.
I see that no suitable answer was given to the the problem.
Please have a look at that.
I am using CI and when i redirect to the view which has the sample script you guys put onto your website I have ssl error...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants