[英]Unable to send sms using plivo api in php
我正在尝试使用 PHP 中的 Plivo API 发送短信,但所有方法都工作正常并且也得到了来自 Plivo 的响应,但我没有从所有这些方法中收到短信?
源代码 1
# Plivo AUTH ID
$AUTH_ID = 'my id';
# Plivo AUTH TOKEN
$AUTH_TOKEN = 'my token';
# SMS sender ID.
$src = 'sender name';
# SMS destination number
$dst = '+92123456789';
# SMS text
$text = 'Hello';
$url = 'https://api.plivo.com/v1/Account/'.$AUTH_ID.'/Message/';
$data = array("src" => "$src", "dst" => "$dst", "text" => "$text");
$data_string = json_encode($data);
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_USERPWD, $AUTH_ID . ":" . $AUTH_TOKEN);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec( $ch );
curl_close($ch);
print_r($response);
源代码 2
$auth_id = 'my auth id';
$auth_token = 'my token';
$src = 'sender number';
$dst = '+92123456789';
$text = 'Hello, this is testing message';
$api = curl_init("https://api.plivo.com/v1/Account/$auth_id/Message/");
curl_setopt_array($api, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => array("Authorization: Basic ".base64_encode($auth_id.':'.$auth_token)),
CURLOPT_POSTFIELDS => array(
'src' =>$src,
'dst' => $dst,
'text' => $text
)
));
$resp = curl_exec($api);
$resp = curl_exec($api);
curl_close($api);
var_dump($resp);
源代码 3
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient("auth_id", "auth_token");
$response = $client->messages->create(
'sender number', // Sender's phone number with country code
['+92123456789'], // receiver's phone number with country code
"Hello, this is a sample text", // Your SMS text message
["url"=>"http://test.com/plivoapi/"]
);
print_r($response);
我已经尝试了所有这些方法来发送 SMS 无法使用 Plivo 获取 SMS 即使我尝试使用不同国家/地区号码获取 SMS
请指导我哪里做错了,或者我需要在 Plivo API 中添加一个 webhook URL 以发送短信?
通过查找问题中的目的地号码,看起来这是一个无效号码。 如果您在这里仍然需要帮助,最好的办法是创建支持票。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.