{"id":15304556,"url":"https://github.com/monkeymars/pusher-php","last_synced_at":"2025-10-08T09:30:43.194Z","repository":{"id":5457279,"uuid":"6651689","full_name":"monkeymars/Pusher-PHP","owner":"monkeymars","description":"PHP Interface to the Pusher API","archived":false,"fork":true,"pushed_at":"2012-08-14T22:41:03.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-02T07:56:58.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"cj/Pusher-PHP","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monkeymars.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}},"created_at":"2012-11-12T10:23:13.000Z","updated_at":"2013-01-13T02:46:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/monkeymars/Pusher-PHP","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/monkeymars%2FPusher-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkeymars%2FPusher-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkeymars%2FPusher-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkeymars%2FPusher-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monkeymars","download_url":"https://codeload.github.com/monkeymars/Pusher-PHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235700110,"owners_count":19031668,"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":[],"created_at":"2024-10-01T07:56:59.014Z","updated_at":"2025-10-08T09:30:42.825Z","avatar_url":"https://github.com/monkeymars.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pusher PHP Library\n\nThis is a very simple PHP library to the Pusher API (http://pusher.com).\nUsing it is easy as pie:\n\n    require('Pusher.php');\n    $pusher = new Pusher($key, $secret, $app_id);\n    \nIf you prefer to use the Singleton pattern usage is similar, but like this:\n\n    require('Pusher.php');\n    $pusher = PusherInstance::get_pusher();\n    \nThen call the appropriate function.\n\n## Trigger\n\nTo trigger an event on a channel use the `trigger` function.\n    \n    $pusher-\u003etrigger('my-channel', 'my_event', 'hello world');\n\nNote: You need to set your API information in Pusher.php\n\n### Arrays\n\nObjects are automatically converted to JSON format:\n\n    $array['name'] = 'joe';\n    $array['message_count'] = 23;\n\n    $pusher-\u003etrigger('my_channel', 'my_event', $array);\n\nThe output of this will be:\n\n    \"{'name': 'joe', 'message_count': 23}\"\n\n### Socket id\n\nIn order to avoid duplicates you can optionally specify the sender's socket id while triggering an event (http://pusherapp.com/docs/duplicates):\n\n    $pusher-\u003etrigger('my-channel','event','data','socket_id');\n\n### Debugging\n\nYou can either turn on debugging by setting the fifth argument to true, like so:\n\n    $pusher-\u003etrigger('my-channel', 'event', 'data', null, true)\n\nor with all requests:\n\n    $pusher = new Pusher($key, $secret, $app_id, true);\n\nOn failed requests, this will return the server's response, instead of false.\n\n### JSON format\n\nIf your data is already encoded in JSON format, you can avoid a second encoding step by setting the sixth argument true, like so:\n\n\t$pusher-\u003etrigger('my-channel', 'event', 'data', null, false, true)\n\n## Authenticating Private channels\n\nTo authorise your users to access private channels on Pusher, you can use the socket_auth function:\n\n    $pusher-\u003esocket_auth('my-channel','socket_id');\n\n## Authenticating Presence channels\n\nUsing presence channels is similar to private channels, but you can specify extra data to identify that particular user:\n\n    $pusher-\u003epresence_auth('my-channel','socket_id', 'user_id', 'user_info');\n\n### Presence example\n\nFirst set this variable in your JS app:\n\n    Pusher.channel_auth_endpoint = '/presence_auth.php';\n\nNext, create the following in presence_auth.php:\n\n    \u003c?php\n    header('Content-Type: application/json');\n    if ($_SESSION['user_id']){\n      $sql = \"SELECT * FROM `users` WHERE id='$_SESSION[user_id]'\";\n      $result = mysql_query($sql,$mysql);\n      $user = mysql_fetch_assoc($result);\n    } else {\n      die('aaargh, no-one is logged in')\n    }\n    \n    $pusher = new Pusher($key, $secret, $app_id);\n    $presence_data = array('name' =\u003e $user['name']);\n    echo $pusher-\u003epresence_auth($_POST['channel_name'], $_POST['socket_id'], $user['id'], $presence_data);\n    ?\u003e\n\nNote: this assumes that you store your users in a table called `users` and that those users have a `name` column. It also assumes that you have a login mechanism that stores the `user_id` of the logged in user in the session.\n\n## Channel Stats\n\nIt's also possible to get statistics about a channel from the Pusher REST API.\n\n    $stats = $pusher-\u003eget_channel_stats('channel-name');\n    $channel_occupied = $stats-\u003eoccupied;\n    \n## Channels list\n\nIt's also possible to get a list of channels for an application from the Pusher REST API.\n\n    $channels = $pusher-\u003eget_channels();\n    $channel_count = count($channels); // $channels is an Array\n\n## License\n\nCopyright 2010, Squeeks. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonkeymars%2Fpusher-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonkeymars%2Fpusher-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonkeymars%2Fpusher-php/lists"}