@@ -23,7 +23,7 @@ class Pusher
2323 */
2424 public function trigger ($ channels , string $ eventName , array $ data , array $ params = [])
2525 {
26- $ params ['channel ' ] = is_string ($ channels ) ? [$ channels ] : (array ) $ channels ;
26+ $ params ['channels ' ] = is_string ($ channels ) ? [$ channels ] : (array ) $ channels ;
2727 $ params ['data ' ] = $ data ;
2828 $ params ['name ' ] = $ eventName ;
2929
@@ -41,23 +41,25 @@ public function trigger($channels, string $eventName, array $data, array $params
4141 */
4242 protected function sendRequest (string $ url , array $ data )
4343 {
44+ $ jsonData = json_encode ($ data );
45+
4446 $ ch = curl_init ($ url );
4547 curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'POST ' );
46- curl_setopt ($ ch , CURLOPT_POSTFIELDS , json_encode ( $ data ) );
48+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ jsonData );
4749 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
4850 curl_setopt (
4951 $ ch ,
5052 CURLOPT_HTTPHEADER ,
5153 [
5254 'Content-Type: application/json ' ,
53- 'Content-Length: ' .strlen ($ data ),
55+ 'Content-Length: ' .strlen ($ jsonData ),
5456 ]
5557 );
5658
5759 $ response = curl_exec ($ ch );
5860
5961 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 );
6163
6264 return false ;
6365 }
@@ -74,7 +76,7 @@ protected function sendRequest(string $url, array $data)
7476 */
7577 protected function getPusherUrl ()
7678 {
77- $ pusherUrl = config ('unicomponent.pusher.configs.pusher_url ' );
79+ $ pusherUrl = config ('unicomponent.components. pusher.configs.pusher_url ' );
7880
7981 throw_unless (filter_var ($ pusherUrl , FILTER_VALIDATE_URL ), '\Exception ' , 'pusher url illegal ' );
8082
0 commit comments