我查找了类似的主题,无法找到任何解决方案, 我希望有人可以帮助我..
注意:我在xampp localhost上运行脚本,我的国家/地区代码是+90 我已经按照Nexmo文档发送了短信。以下是php脚本。
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxxxxx',
'api_secret' => 'xxxxxxxxxxx',
'to' => 90542xxxxxxx,
'from' => 'MyCompanyName',
'text' => 'Working'
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
?>
以下是结果。好像它正在发送它但是我没有在我的手机上收到短信可能导致这种情况?
{ "message-count": "1", "messages": [{ "to": "90542xxxxxxx", "message-id": "0C00000016FF36E9", "status": "0", "remaining-balance": "1.77080000", "message-price": "0.01910000", "network": "28602" }] }
答案 0 :(得分:1)
可能尚未发送短信的原因:
NXSMS
。有关支持字母数字发件人ID的详细信息,请参阅:
https://docs.nexmo.com/messaging/sms-api/building-global-apps#country_specific_features 提高可传递性的一种方法是使用通过Nexmo购买的from
号码。在这些示例中,还有一个callback
参数集,以便通知应用程序SMS传送。
<?php
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET));
$message = $client->message()->send([
'to' => '90542xxxxxxx',
'from' => '90555xxxxxxx',
'text' => 'Working',
'callback' => 'https://example.com/dlr;
]);
或者基于问题中的代码:
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxxxxx',
'api_secret' => 'xxxxxxxxxxx',
'to' => '90542xxxxxxx',
'from' => '90555xxxxxxx',
'text' => 'Working',
'callback' => 'https://example.com/dlr;
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;