{"action":"closed","issue":{"url":"https://api.github.com/repos/hoaproject/Websocket/issues/41","labels_url":"https://api.github.com/repos/hoaproject/Websocket/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/hoaproject/Websocket/issues/41/comments","events_url":"https://api.github.com/repos/hoaproject/Websocket/issues/41/events","html_url":"https://github.com/hoaproject/Websocket/issues/41","id":91822034,"number":41,"title":"How to broadcast events to websocket server with URL wss://xxx.xx","user":{"login":"shulard","id":482993,"avatar_url":"https://avatars.githubusercontent.com/u/482993?v=3","gravatar_id":"","url":"https://api.github.com/users/shulard","html_url":"https://github.com/shulard","followers_url":"https://api.github.com/users/shulard/followers","following_url":"https://api.github.com/users/shulard/following{/other_user}","gists_url":"https://api.github.com/users/shulard/gists{/gist_id}","starred_url":"https://api.github.com/users/shulard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shulard/subscriptions","organizations_url":"https://api.github.com/users/shulard/orgs","repos_url":"https://api.github.com/users/shulard/repos","events_url":"https://api.github.com/users/shulard/events{/privacy}","received_events_url":"https://api.github.com/users/shulard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hoaproject/Websocket/labels/difficulty:%20medium","name":"difficulty: medium","color":"F0788C"},{"url":"https://api.github.com/repos/hoaproject/Websocket/labels/in%20progress","name":"in progress","color":"ededed"},{"url":"https://api.github.com/repos/hoaproject/Websocket/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"Hywan","id":946104,"avatar_url":"https://avatars.githubusercontent.com/u/946104?v=3","gravatar_id":"","url":"https://api.github.com/users/Hywan","html_url":"https://github.com/Hywan","followers_url":"https://api.github.com/users/Hywan/followers","following_url":"https://api.github.com/users/Hywan/following{/other_user}","gists_url":"https://api.github.com/users/Hywan/gists{/gist_id}","starred_url":"https://api.github.com/users/Hywan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hywan/subscriptions","organizations_url":"https://api.github.com/users/Hywan/orgs","repos_url":"https://api.github.com/users/Hywan/repos","events_url":"https://api.github.com/users/Hywan/events{/privacy}","received_events_url":"https://api.github.com/users/Hywan/received_events","type":"User","site_admin":false},"milestone":null,"comments":23,"created_at":"2015-06-29T14:30:42Z","updated_at":"2015-07-27T06:50:11Z","closed_at":"2015-07-27T06:50:11Z","body":"Hello,\r\n\r\nI'm currently trying to implement slack bot stuff using PHP. I found that there is an awesome Real Time Messaging API which using websockets (https://api.slack.com/rtm).\r\n\r\nI tried to implement a method which can follow the given steps :\r\n\r\n* call : https://api.slack.com/methods/rtm.start\r\n* extract the websocket URL (key url in the JSON)\r\n* connect to the websocket\r\n* broadcast message\r\n\r\nI found that Hoaproject as an awesome WebSocket client/server but I can't find a way to do that...\r\n\r\nA websocket URL given by Slack API (they have a lifetime of 30sec): `wss://ms177.slack-msgs.com/websocket/GEjhTU7tHl3C90SwJuKaF71Orb8F9HZgdv-HIwf4HxIMygveAW9xc2X_bZb_LtDXLVAapy7nTJ7qh9Oz0zYnyrr7Gn2kD4635oihxNh3ZTM=.`\r\n\r\nHere the code I used to do that :\r\n```php\r\n<?php\r\nrequire_once __DIR__.'/vendor/autoload.php';\r\n\r\n$rtmStart = \"https://slack.com/api/rtm.start?token=\".$argv[1];\r\n$content = json_decode(file_get_contents($rtmStart));\r\n\r\n$client = new Hoa\\Websocket\\Client( new Hoa\\Socket\\Client($url) );\r\n$client->connect();\r\n\r\n$client->send('{\r\n     \"type\": \"message\",\r\n     \"channel\": \"XXX\",\r\n     \"user\": \"XXX\",\r\n     \"text\": \"Hello world\",\r\n     \"ts\": \"'.microtime(true).'\"\r\n}');\r\n\r\n$client->close();\r\n```\r\n\r\nThanks :)"}}