nexmo 短信 api 不工作
nexmo sms api is not working
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxx',
'api_secret' => 'xxxxxxx',
'to' => $mobile,
'from' => 'ABC',
'text' => $message,
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
此 api 没有工作并且没有显示任何错误。我仅使用此代码发送短信还需要其他任何代码吗?
我使用 api_key 并且秘密正确。
assuming that you checked values of $mobile and $message before using and that they're ok
编辑:error_reporting(E_ALL); ini_set('display_errors', 1);
在您的页面顶部并检查更新的代码
编辑 2:
It works only with your registered phone number with trial API and with registered number as dest
This is meant to avoid spam
你需要像这样输入 $mobile
和 $message
:
error_reporting(E_ALL); ini_set('display_errors', 1);
print_r($_POST);
echo"[ num: $mobile / mess: $message]";
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxx',
'api_secret' => 'xxxxxx',
'to' => ''.$mobile.'', /* dest phone number */
'from' => '33012345678', /* my own phone number */
'text' => ''.$message.'' /* my message */
]
);
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxx',
'api_secret' => 'xxxxxxx',
'to' => $mobile,
'from' => 'ABC',
'text' => $message,
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
此 api 没有工作并且没有显示任何错误。我仅使用此代码发送短信还需要其他任何代码吗? 我使用 api_key 并且秘密正确。
assuming that you checked values of $mobile and $message before using and that they're ok
编辑:error_reporting(E_ALL); ini_set('display_errors', 1);
在您的页面顶部并检查更新的代码
编辑 2:
It works only with your registered phone number with trial API and with registered number as dest This is meant to avoid spam
你需要像这样输入 $mobile
和 $message
:
error_reporting(E_ALL); ini_set('display_errors', 1);
print_r($_POST);
echo"[ num: $mobile / mess: $message]";
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxx',
'api_secret' => 'xxxxxx',
'to' => ''.$mobile.'', /* dest phone number */
'from' => '33012345678', /* my own phone number */
'text' => ''.$message.'' /* my message */
]
);