Closed manthan787 closed 8 years ago
@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.
@cachrisman Yes it's working perfectly now!
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.
@dbelieves are you using the latest version of the plivo-php helper library? please share the code you use to send sms.
@cachrisman, its resolved. had smart quotes in query.
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?
@Amarja can you post your composer.json and the code where you use a Plivo function which causes this error?
@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.
<?php require 'vendor/autoload.php'; use Plivo\RestAPI;
$auth_id = "XXXXXXXXXXXXXXXXXXXX"; $auth_token = "XXXXXXXXXXMjIzODExMTg3NzZXXXXX";
$p = new Plivo\RestAPI($auth_id, $auth_token);
// Set message parameters $params = array( 'src' => '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]}
";
?>
@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
@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?
@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?
@cachrisman Thanks so much for your reply, I will try this..
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 <?php require 'plivo.php';
$auth_id = "xxxxxx";
$auth_token = "xxxxx";
$p = new RestAPI($auth_id, $auth_token);
// Send a message
$params = array(
'src' => '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 "<br> Api ID : {$response['response']['api_id']} <br>";
// Print the Message UUID
echo "Message UUID : {$response['response']['message_uuid'][0]} <br>";
?>
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.
@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.
@Ramya-Raghu thanks for your quick reply. I will go through it.
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"] } }
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
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.
@amarja that code will work provided src
is a valid Number in your account. Is that not working?
@cachrisman Thanks, now it's working properly :)
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...
I get the following error while trying to make a POST request to send 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?