简体   繁体   English

无法在 php 中使用 plivo api 发送短信

[英]Unable to send sms using plivo api in php

I'm trying to send SMS using Plivo API in PHP but all methods are working fine and also get a response from Plivo but I'm not getting SMS from all these methods?我正在尝试使用 PHP 中的 Plivo API 发送短信,但所有方法都工作正常并且也得到了来自 Plivo 的响应,但我没有从所有这些方法中收到短信?

Source Code 1源代码 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);

Source Code 2源代码 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);

Source Code 3源代码 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);

I have tried all these methods to send the SMS unable to get SMS using Plivo even I have tried to get SMS with the different countries number我已经尝试了所有这些方法来发送 SMS 无法使用 Plivo 获取 SMS 即使我尝试使用不同国家/地区号码获取 SMS

Please guide me where I'm doing wrong or I need to add a webhook URL in Plivo API for the sending SMS?请指导我哪里做错了,或者我需要在 Plivo API 中添加一个 webhook URL 以发送短信?

From looking up the destination number in the question, it looks like that's an invalid number.通过查找问题中的目的地号码,看起来这是一个无效号码。 If you still need help here, your best bet would be to create a support ticket .如果您在这里仍然需要帮助,最好的办法是创建支持票

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM