简体   繁体   English

使用 laravel 通过 Signalwire api 发送短信时出现错误“调用成员 function send() on null”

[英]getting error "Call to a member function send() on null" while sending sms through Signalwire api using laravel

Using relay client api to send sms from Signalwire it gives an error message使用中继客户端 api 从 Signalwire 发送短信时会出现错误消息

"Call to a member function send() on null" in file vendor\signalwire\signalwire\src\Relay\Connection.php文件 vendor\signalwire\signalwire\src\Relay\Connection.php 中的“调用成员 function send() on null”

$this->_ws->send($msg->toJson()); $this->_ws->send($msg->toJson());

I am using these code below我在下面使用这些代码

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';
    }
});

Attach an event handler for sending messages.附加用于发送消息的事件处理程序。

$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 method indicates that the session has been established and all other methods can now be used. signalwire.ready方法表示 session 已经建立,现在可以使用所有其他方法。

So with the use of this event handler, you can resolve the bug "Call to a member function send() on null" in the file.因此,使用此事件处理程序,您可以解决文件中的错误“Call to a member function send() on null”。

暂无
暂无

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

相关问题 在通过 Laravgel API 使用请求验证 class 时,对 Z37A62786688DAFFD29 上的成员 functionvalidated() 的错误调用 - While using request validation class through Laravgel API, Error Call to a member function validated() on null 在 null 上调用成员函数 addEagerConstraints() 在 laravel 6 上出现此错误 - Call to a member function addEagerConstraints() on null getting this error on laravel 6 osiset / laravel-shopify 错误调用 null 上的成员 function api() - osiset / laravel-shopify Error Call to a member function api() on null 使用 laravel orm 时出现错误“呼叫成员 function count() on null” - error “Call to a member function count() on null” when using laravel orm 在 Laravel 中使用背包时,调用成员 function hasAccessOrFail() on null 错误 - Call to a member function hasAccessOrFail() on null error when using backpack in Laravel 在运行 laravel phpunit 测试用例时,我在 Model.php 第 1249 行收到错误“调用成员函数 connection() on null” - While running laravel phpunit testcase , i'm getting an error "Call to a member function connection() on null" in Model.php line 1249 Laravel错误:在null上调用成员函数store() - Laravel error: Call to a member function store() on null Laravel 调用成员 function getName() on null 错误 - Laravel Call to a member function getName() on null Error 在 null 上调用成员 function getClientOriginalName() 时出错 - Laravel 8 - Error Call to a member function getClientOriginalName() on null - Laravel 8 错误,对成员函数send()的调用为null - ERROR, Call to a member function send() on null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM