pusher / chatkit-server-php

PHP SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
35 stars 20 forks source link

Path to sendMessage #23

Closed mludi closed 6 years ago

mludi commented 6 years ago

I'm trying to use the SDK to send a message to a room. I always got the error message

Here is my code to send

        $chatkit->sendMessage([
            'sender_id' => 'my-sender-id',
            'room_id' => 'my-room-id',
            'text' => 'yolo'
        ]);
"message": "Unsupported request path",
    "exception": "Chatkit\\Exceptions\\ChatkitException",
    "file": "/var/www/html/vendor/pusher/pusher-chatkit-server/src/Chatkit.php",
    "line": 556,

That's the dumped curl stack

curl resource @10
  url: "https://us1.pusherplatform.io/services/chatkit/v1/my-instance-locator/rooms/my-room-id"
  content_type: null
  http_code: 0
  header_size: 0
  request_size: 0
  filetime: -1
  ssl_verify_result: 0
  redirect_count: 0
  total_time: 0.0
  namelookup_time: 0.0
  connect_time: 0.0
  pretransfer_time: 0.0
  size_upload: 0.0
  size_download: 0.0
  speed_download: 0.0
  speed_upload: 0.0
  download_content_length: -1.0
  upload_content_length: -1.0
  starttransfer_time: 0.0
  redirect_time: 0.0
  redirect_url: ""
  primary_ip: ""
  certinfo: []
  primary_port: 0
  local_ip: ""
  local_port: 0
}

and here the full response

array:2 [
  "body" => array:3 [
    "error" => "services/chatkit_authorizer/authorization/unknown_request_path"
    "error_description" => "Unsupported request path"
    "error_uri" => "https://docs.pusher.com/errors/services/chatkit_authorizer/authorization/unknown_request_path"
  ]
  "status" => 401
]

The token for the user was created and attached, the room is public and I'm a member.

Any ideas?

callum-oakley commented 6 years ago

Hi @mludi, what version of the SDK are you using? The path should be

.../rooms/my-room-id/messages

Looks like your curl is missing the /messages for some reason?

mludi commented 6 years ago

Hi @callum-oakley, it was a big fault I made.

I used the room name instead the room_id to send the message to.

I was able get the correct path with the chrome network inspector and sending a message from your dashboard.

Sorry and thanks for the great work.

callum-oakley commented 6 years ago

Ahh good to hear! Thanks for following up :)