BulkSMS.link Guzzle和laravel 500内部服务器错误

时间:2018-10-08 08:44:37

标签: guzzle

我正在尝试通过bulksms api发送短信,但是我从狂饮中收到了500个内部服务器错误异常。

Server error: `POST https://dashboard.bulksms.link/api-v1` resulted in a `500 Internal Server Error` response: <!DOCTYPE html> <html> <head> <meta name="robots" content="noindex,nofollow" /> <style> (truncated...)

枪口设置:

    $this->app->singleton('GuzzleHttp\Client', function($app){
        return new \GuzzleHttp\Client([
            'headers' => [
                'Content-Type' => 'application/json',
                'Accept' => 'application/json',
                'BulkSMS-Token' => env('BULK_SMS_API_KEY'),
            ]
        ]);
    });

然后在我的控制器中

    $response = $this->client->request('POST', $this->url, [
        'json' => [
            'to' => '' //Number removed for privacy,
            'from' => $this->appId,
            'message' => 'Testing'
        ]
    ]);

    dd($response->getBody()->getContents());

这是使用枪口发布JSON数据的正确方法吗?还是我错过了什么?

0 个答案:

没有答案