php 我正在使用franzose/laravel-smpp包发送短信,但得到这个错误:socket_close():参数#1($socket)必须是Socket类型,给定为null

83qze16e  于 2023-06-21  发布在  PHP
关注(0)|答案(1)|浏览(115)

这个配置文件:

'providers' => [
        'example' => [
            'host' => '10.120.2.41',
            'port' => 10010,
            'timeout' => 90,
            'login' => 'test',
            'password' => 'test'
        ]
    ],
<?php

命名空间App\Http\Controllers;
使用LaravelSmpp\SmppServiceInterface;
class SmsController extends Controller {

protected $smpp;

public function __construct(SmppServiceInterface $smpp)
{
    $this->smpp = $smpp;
}

public function send()
{
    $this->smpp->sendOne('211912230091', 'SMS message');
}

}

w1jd8yoj

w1jd8yoj1#

尝试使用此库:https://github.com/alexandr-mironov/php-smpp
自述文件中的示例对我来说非常好,你可以在配置文件中添加这样的内容:

'sms' => [
            'host' => env('SMS_HOST','127.0.0.1'),
            'port' => env('SMS_PORT'),
            'user' => env('SMS_USER'),
            'password' => env('SMS_PASSWORD'),
            'sender' => env('SMS_SENDER'),
            'timeout' => env('SMS_TIMEOUT', 10000),
            'npi' => [
                'src' => env('SMS_SRC_NPI', 1),
                'dst' => env('SMS_DST_NPI', 1),
            ],
            'ton' => [
                'src' => env('SMS_SRC_TON', 1),
                'dst' => env('SMS_DST_TON', 1),
            ]
        ],

祝你好运

相关问题