[英]How to send sms by plivo api it require autoload.php
How to send sms by plivo api it say require vendor/autoload.php But i cannot find any autoload.php , it have also composer.json when i run this is get error如何通过 plivo api 发送短信它说需要 vendor/autoload.php 但我找不到任何 autoload.php ,当我运行时它也有 composer.json 这是得到错误
Class 'GuzzleHttp\\Client' not found找不到类“GuzzleHttp\\Client”
here the my code这是我的代码
<form action="send_sms_from_browser.php" method="post">
From No:<input type="text" name="From"><br><br>
To No:<input type="text" name="To"><br><br>
Message:<br>
<textarea name="Text" rows="3" cols="30" >Message Text</textarea><br> <br>
<input type="submit" value="Send SMS">
</form>
error_reporting(E_ALL);
require_once 'vendor/autoload.php';
use Plivo\RestAPI;
$to = $_POST['To'];
$from = $_POST['From'];
$text = $_POST['Text'];
echo "<br/>Sent Message info:<br/><br/>To: $to<br/>";
echo "From: $from <br/>";
echo "Message: $text <br/>";
$auth_id = 'Auth id';
$auth_token = "Token";
$p = new RestAPI($auth_id, $auth_token);
print_r($p);
// Send a message
$params = array(
'src' => "$from",
'dst' => "$to",
'text' => "$text",
'type' => 'sms',
);
$response = $p->send_message($params);
echo $response[0];
if (array_shift(array_values($response)) == "202")
{
echo "<br/><br/>Message status: Sent";
}
else
{
echo "<br/><br/>Error: Please ensure that From number is a valid";
}
Thank you now i solved this by myself this is the code hope this is useful for you guys..谢谢你现在我自己解决了这个代码希望这对你们有用..
$ch = curl_init();
$data = '{"src": "source number with country code","dst": "receiver with country code", "text": "Hi, text from Plivo"}';
curl_setopt($ch, CURLOPT_URL, "https://api.plivo.com/v1/Account/AUTH_ID/Message/");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_USERPWD, "AUTH_ID:TOKEN_ID");
$result = curl_exec($ch);
print_r($result);exit;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.