{"id":18746103,"url":"https://github.com/diloabininyeri/rest-socket","last_synced_at":"2025-10-18T13:59:03.713Z","repository":{"id":109642872,"uuid":"383728223","full_name":"diloabininyeri/rest-socket","owner":"diloabininyeri","description":"Send socket notification on HTTP rest API","archived":false,"fork":false,"pushed_at":"2022-08-02T09:43:48.000Z","size":1734,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T16:11:32.307Z","etag":null,"topics":["php7","rest-api","socket-io"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diloabininyeri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-07T08:30:28.000Z","updated_at":"2022-10-10T12:43:16.000Z","dependencies_parsed_at":"2023-04-05T02:48:57.993Z","dependency_job_id":null,"html_url":"https://github.com/diloabininyeri/rest-socket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diloabininyeri%2Frest-socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diloabininyeri%2Frest-socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diloabininyeri%2Frest-socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diloabininyeri%2Frest-socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diloabininyeri","download_url":"https://codeload.github.com/diloabininyeri/rest-socket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248636709,"owners_count":21137507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php7","rest-api","socket-io"],"created_at":"2024-11-07T16:20:57.993Z","updated_at":"2025-10-18T13:59:03.640Z","avatar_url":"https://github.com/diloabininyeri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# socket.io rest \nsend to message or data with any software langauge,no need more enviroument just use http rest api\n\n\nget from docker hub...\n```console\ndocker run --name rest-socket -p 3000:3000 diloabininyeri/rest-socket\n```\n\nand see it\n```\nhttp://localhost:3000\n```\n\nwith js example code \n\n```js\nfunction socket_emit(channel, json) {\n    let query = new URLSearchParams(json).toString();\n    fetch(`http://172.16.45.131:3000/${channel}/?token=${token}`, {\n        method: 'POST',\n        headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n        body: query\n    }).then(a =\u003e a.json()).then(e =\u003e console.log(e));\n}\n\nsocket_emit('notify', {seen: 45})\n\nsocket.on(\"notify\", (a) =\u003e console.log(a))\n\n```\nUsing on laravel \n\n```php\n\nuse Illuminate\\Support\\Facades\\Http;\n\n$url = 'http://localhost:3000/chanel_name?token=$2y$10$.5iuqFaSaMQrPi/rMmUVjOJg/Ip6gEI5Jzhux.tzfyUu2ZmPOAs2C';\n\n\n$payload = ['name' =\u003e 'Dılo sürücü'];\n\n$response = Http::asForm()\n    -\u003epost(\n        $url,\n        $payload\n    );\n\nreturn $response-\u003ebody();\n\n```\n\nsend data to socket with php\n```php\n$url = \"http://localhost:3000/chanelname?token=$2y$10$.5iuqFaSaMQrPi/rMmUVjOJg/Ip6gEI5Jzhux.tzfyUu2ZmPOAs2C\";\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL,$url);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS,\"name=dılo\u0026surname=sürücü\");\n.\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n\n$server_output = curl_exec($ch);\n\n\n\ncurl_close ($ch);\n\n```\nexample subscribe to socket in html via js \n\n```js\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js\"\n        integrity=\"sha512-eVL5Lb9al9FzgR63gDs1MxcDS2wFu3loYAgjIH0+Hg38tCS8Ag62dwKyH+wzDb+QauDpEZjXbMn11blw8cbTJQ==\"\n        crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n\n    const token = \"$2y$10$.5iuqFaSaMQrPi/rMmUVjOJg/Ip6gEI5Jzhux.tzfyUu2ZmPOAs2C\";\n    const uri = \"yoursocketserver.com:3000\";\n\n    let socket = io(uri, {auth: {token: token}});\n    \n    function socket_emit(channel, json) {\n    let query = new URLSearchParams(json).toString();\n    fetch(`http://172.16.45.131:3000/${channel}/?token=${token}`, {\n        method: 'POST',\n        headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n        body: query\n    }).then(a =\u003e a.json()).then(e =\u003e console.log(e));\n}\n\n\n    socket.on('connect_error', (error) =\u003e console.error(error));\n    socket.on(\"my-channel\",(a)=\u003ealert(JSON.stringify(a)))\n    \n    socket_emit(\"my-channel\",{name:\"dılo\"});\n    \n \n\u003c/script\u003e\n\n \n```\n\nTest with curl\n\n```console\ncurl --location --request GET 'http://localhost:3000/chanel_name?token=$2y$10$/GluV3g/0wcaU5A301pd0O1EeucaOrZym2Yh9CCti6NwROwnk4vba' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--data-urlencode 'name=Dılo sürücü'\n```\n![screenshot of postman](https://i.ibb.co/MGnzYPz/Screenshot-from-2022-03-08-14-53-41.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiloabininyeri%2Frest-socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiloabininyeri%2Frest-socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiloabininyeri%2Frest-socket/lists"}