使用Nexmo发送短信,使用私人网络时失败
问题描述:
当我使用直接互联网(开放网络)时,我的代码正在工作。但是当我试图使用专用网络(我目前在我的公司使用),我得到这个错误。使用Nexmo发送短信,使用私人网络时失败
警告:在E中的foreach()提供的参数无效:\文件\ XAMPP \ XAMPP \ htdocs中\ nexmo的\ src \ NexmoMessage.php上线228
下面是我发送代码消息..
<?php
include ("src/NexmoMessage.php");
if(isset($_POST['sendMessage'])){
$to = $_POST['to'];
$message = $_POST['smsMessage'];
// Step 1: Declare new NexmoMessage.
$nexmo_sms = new NexmoMessage('xxxxxxxx', 'xxxxxxxxx');
// Step 2: Use sendText($to, $from, $message) method to send a message.
$info = $nexmo_sms->sendText($to, 'NexmoWorks', $message);
// Step 3: Display an overview of the message
//echo $nexmo_sms->displayOverview($info);
// Done!
}
?>
以下是代码,我有一个错误。
foreach($obj as $key => $val){
// If we come across another class/array, normalise it
if ($val instanceof stdClass || is_array($val)) {
$val = $this->normaliseKeys($val);
}
// Replace any unwanted characters in they key name
if ($is_obj) {
$new_obj->{str_replace('-', '', $key)} = $val;
} else {
$new_obj[str_replace('-', '', $key)] = $val;
}
}
我是否正确地假设您使用了2台不同的服务器?如果这样error_reporting(php.net/error_reporting)可能默认为两个不同的值。 –
请阅读[在什么情况下,我可以添加“紧急”或其他类似的短语到我的问题,以获得更快的答案?](/ meta.stackoverflow.com/q/326569) - 总结是,这不是这是解决志愿者问题的理想方式,可能会对获得答案产生反作用。请不要将这添加到您的问题。 – halfer
@PeterM我使用了两个不同的网络。一个是开放网络或直接互联网,另一个是我们公司内部使用的网络,实际上我们必须在公司内使用我们的网络来完成这项工作,但它失败了,所以我尝试使用直接互联网要知道我的代码或我们正在使用的互联网有什么问题.. – AllRight