-2

如何通过 plivo api 发送短信它说需要供应商/autoload.php 但我找不到任何 autoload.php,当我运行它时它也有 composer.json 这是错误

找不到类“GuzzleHttp\Client”

这是我的代码

<form action="send_sms_from_browser.php" method="post">
From No:<input type="text" name="From"><br><br>
To&nbsp;&nbsp;&nbsp;&nbsp;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";
}
4

1 回答 1

0

谢谢你现在我自己解决了这是代码希望这对你们有用..

$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;
于 2016-10-14T13:38:15.297 回答