{"id":19307445,"url":"https://github.com/discord-php/discordphp-http","last_synced_at":"2025-04-05T22:09:51.769Z","repository":{"id":42512490,"uuid":"326086876","full_name":"discord-php/DiscordPHP-Http","owner":"discord-php","description":"Asynchronous HTTP client used for communication with the Discord REST API.","archived":false,"fork":false,"pushed_at":"2024-12-27T20:07:48.000Z","size":125,"stargazers_count":23,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T21:09:10.860Z","etag":null,"topics":["discord","discord-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discord-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-01-02T01:29:05.000Z","updated_at":"2025-02-07T06:15:13.000Z","dependencies_parsed_at":"2024-06-18T16:55:10.241Z","dependency_job_id":"570ddd0b-eef4-4f8b-a050-87d5828211db","html_url":"https://github.com/discord-php/DiscordPHP-Http","commit_stats":{"total_commits":94,"total_committers":10,"mean_commits":9.4,"dds":0.5851063829787234,"last_synced_commit":"0a9981dd5f8f96071f54d45e8d6fff2c6c295eb6"},"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-php%2FDiscordPHP-Http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-php%2FDiscordPHP-Http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-php%2FDiscordPHP-Http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-php%2FDiscordPHP-Http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discord-php","download_url":"https://codeload.github.com/discord-php/DiscordPHP-Http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406111,"owners_count":20933806,"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":["discord","discord-api"],"created_at":"2024-11-10T00:10:59.542Z","updated_at":"2025-04-05T22:09:51.736Z","avatar_url":"https://github.com/discord-php.png","language":"PHP","readme":"# DiscordPHP-Http\n\nAsynchronous HTTP client used for communication with the Discord REST API.\n\n## Requirements\n\n- PHP \u003e=7.4\n\n## Installation\n\n```sh\n$ composer require discord-php/http\n```\n\nA [psr/log](https://packagist.org/packages/psr/log)-compliant logging library is also required. We recommend [monolog](https://github.com/Seldaek/monolog) which will be used in examples.\n\n## Usage\n\n```php\n\u003c?php\n\ninclude 'vendor/autoload.php';\n\nuse Monolog\\Logger;\nuse Monolog\\Handler\\StreamHandler;\nuse Discord\\Http\\Http;\nuse Discord\\Http\\Drivers\\React;\n\n$loop = \\React\\EventLoop\\Factory::create();\n$logger = (new Logger('logger-name'))-\u003epushHandler(new StreamHandler('php://output'));\n$http = new Http(\n    'Bot xxxx.yyyy.zzzz',\n    $loop,\n    $logger\n);\n\n// set up a driver - this example uses the React driver\n$driver = new React($loop);\n$http-\u003esetDriver($driver);\n\n// must be the last line\n$loop-\u003erun();\n```\n\nAll request methods have the same footprint:\n\n```php\n$http-\u003eget(string $url, $content = null, array $headers = []);\n$http-\u003epost(string $url, $content = null, array $headers = []);\n$http-\u003eput(string $url, $content = null, array $headers = []);\n$http-\u003epatch(string $url, $content = null, array $headers = []);\n$http-\u003edelete(string $url, $content = null, array $headers = []);\n```\n\nFor other methods:\n\n```php\n$http-\u003equeueRequest(string $method, string $url, $content, array $headers = []);\n```\n\nAll methods return the decoded JSON response in an object:\n\n```php\n// https://discord.com/api/v8/oauth2/applications/@me\n$http-\u003eget('oauth2/applications/@me')-\u003edone(function ($response) {\n    var_dump($response);\n}, function ($e) {\n    echo \"Error: \".$e-\u003egetMessage().PHP_EOL;\n});\n```\n\nMost Discord endpoints are provided in the [Endpoint.php](src/Discord/Endpoint.php) class as constants. Parameters start with a colon,\ne.g. `channels/:channel_id/messages/:message_id`. You can bind parameters to then with the same class:\n\n```php\n// channels/channel_id_here/messages/message_id_here\n$endpoint = Endpoint::bind(Endpoint::CHANNEL_MESSAGE, 'channel_id_here', 'message_id_here');\n\n$http-\u003eget($endpoint)-\u003edone(...);\n```\n\nIt is recommended that if the endpoint contains parameters you use the `Endpoint::bind()` function to sort requests into their correct rate limit buckets.\nFor an example, see [DiscordPHP](https://github.com/discord-php/DiscordPHP).\n\n## License\n\nThis software is licensed under the MIT license which can be viewed in the [LICENSE](LICENSE) file.\n\n## Credits\n\n- [David Cole](mailto:david.cole1340@gmail.com)\n- All contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord-php%2Fdiscordphp-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscord-php%2Fdiscordphp-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord-php%2Fdiscordphp-http/lists"}