![](/img/trans.png)
[英]While using request validation class through Laravgel API, Error Call to a member function validated() on null
[英]getting error "Call to a member function send() on null" while sending sms through Signalwire api using laravel
使用中繼客戶端 api 從 Signalwire 發送短信時會出現錯誤消息
文件 vendor\signalwire\signalwire\src\Relay\Connection.php 中的“調用成員 function send() on null”
$this->_ws->send($msg->toJson());
我在下面使用這些代碼
use SignalWire\Relay\Client;
$client = new Client(['project' =>'project_id','token' => 'token_id']);
$params = [
'context' => 'office',
'from' => '+1++++',
'to' => '+1++++',
'body' => 'Welcome at SignalWire!'
];
Log::info('Sending SMS..');
$client->messaging->send($params)->done( function ($sendResult){
if ($sendResult->isSuccessful()) {
Log::info('SMS queued successfully!');
echo 'success';
} else {
Log::warning('Error sending SMS!');
echo 'error';
}
});
附加用於發送消息的事件處理程序。
$client->on('signalwire.ready', function($client) use ($params){
$client->messaging->send($params)->done( function ($sendResult)
if ($sendResult->isSuccessful()) {
echo "Message ID: " . $sendResult->getMessageId();
} else {
echo 'error';
}
});
})->on('signalwire.error', function(\Exception $error) {
echo "Error";
});
signalwire.ready
方法表示 session 已經建立,現在可以使用所有其他方法。
因此,使用此事件處理程序,您可以解決文件中的錯誤“Call to a member function send() on null”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.