@@ -23,7 +23,7 @@ class Pusher
23
23
*/
24
24
public function trigger ($ channels , string $ eventName , array $ data , array $ params = [])
25
25
{
26
- $ params ['channel ' ] = is_string ($ channels ) ? [$ channels ] : (array ) $ channels ;
26
+ $ params ['channels ' ] = is_string ($ channels ) ? [$ channels ] : (array ) $ channels ;
27
27
$ params ['data ' ] = $ data ;
28
28
$ params ['name ' ] = $ eventName ;
29
29
@@ -41,23 +41,25 @@ public function trigger($channels, string $eventName, array $data, array $params
41
41
*/
42
42
protected function sendRequest (string $ url , array $ data )
43
43
{
44
+ $ jsonData = json_encode ($ data );
45
+
44
46
$ ch = curl_init ($ url );
45
47
curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'POST ' );
46
- curl_setopt ($ ch , CURLOPT_POSTFIELDS , json_encode ( $ data ) );
48
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ jsonData );
47
49
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
48
50
curl_setopt (
49
51
$ ch ,
50
52
CURLOPT_HTTPHEADER ,
51
53
[
52
54
'Content-Type: application/json ' ,
53
- 'Content-Length: ' .strlen ($ data ),
55
+ 'Content-Length: ' .strlen ($ jsonData ),
54
56
]
55
57
);
56
58
57
59
$ response = curl_exec ($ ch );
58
60
59
61
if ($ response === false ) {
60
- logger ()->error ('[LaravelUnicomponent] Pusher Send Request Error, data: ' .json_encode ( $ data ) );
62
+ logger ()->error ('[LaravelUnicomponent] Pusher Send Request Error, data: ' .$ jsonData );
61
63
62
64
return false ;
63
65
}
@@ -74,7 +76,7 @@ protected function sendRequest(string $url, array $data)
74
76
*/
75
77
protected function getPusherUrl ()
76
78
{
77
- $ pusherUrl = config ('unicomponent.pusher.configs.pusher_url ' );
79
+ $ pusherUrl = config ('unicomponent.components. pusher.configs.pusher_url ' );
78
80
79
81
throw_unless (filter_var ($ pusherUrl , FILTER_VALIDATE_URL ), '\Exception ' , 'pusher url illegal ' );
80
82
0 commit comments