{"id":19888891,"url":"https://github.com/paypal/paypalhttp_php","last_synced_at":"2025-04-06T16:14:39.610Z","repository":{"id":47069925,"uuid":"212407365","full_name":"paypal/paypalhttp_php","owner":"paypal","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-23T19:50:01.000Z","size":10163,"stargazers_count":43,"open_issues_count":5,"forks_count":20,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-13T19:27:26.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/paypal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2019-10-02T18:00:38.000Z","updated_at":"2024-06-18T12:34:07.109Z","dependencies_parsed_at":"2024-06-18T12:34:00.692Z","dependency_job_id":"b2417a73-f827-4722-a2e5-cc9d4760a5c1","html_url":"https://github.com/paypal/paypalhttp_php","commit_stats":{"total_commits":68,"total_committers":12,"mean_commits":5.666666666666667,"dds":0.6470588235294117,"last_synced_commit":"7b09c89c80828e842c79230e7f156b61fbb68d25"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paypal%2Fpaypalhttp_php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paypal%2Fpaypalhttp_php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paypal%2Fpaypalhttp_php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paypal%2Fpaypalhttp_php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paypal","download_url":"https://codeload.github.com/paypal/paypalhttp_php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509237,"owners_count":20950232,"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-11-12T18:08:34.370Z","updated_at":"2025-04-06T16:14:39.580Z","avatar_url":"https://github.com/paypal.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## PayPal HttpClient\n\nPayPalHttp is a generic HTTP Client.\n\nIn it's simplest form, an [`HttpClient`](lib/PayPalHttp/HttpClient.php) exposes an `execute` method which takes an [HTTP request](lib/PayPalHttp/HttpRequest.php), executes it against the domain described in an [Environment](lib/PayPalHttp/Environment.php), and returns an [HTTP response](lib/PayPalHttp/HttpResponse.php).\n\n### Environment\n\nAn [`Environment`](./lib/PayPalHttp/environment.rb) describes a domain that hosts a REST API, against which an `HttpClient` will make requests. `Environment` is a simple interface that wraps one method, `baseUrl`.\n\n```php\n$env = new Environment('https://example.com');\n```\n\n### Requests\n\nHTTP requests contain all the information needed to make an HTTP request against the REST API. Specifically, one request describes a path, a verb, any path/query/form parameters, headers, attached files for upload, and body data.\n\n### Responses\n\nHTTP responses contain information returned by a server in response to a request as described above. They are simple objects which contain a status code, headers, and any data returned by the server.\n\n```php\n$request = new HttpRequest(\"/path\", \"GET\");\n$request-\u003ebody[] = \"some data\";\n\n$response = $client-\u003eexecute($req);\n\n$statusCode = $response-\u003estatusCode;\n$headers = $response-\u003eheaders;\n$data = $response-\u003eresult;\n```\n\n### Injectors\n\nInjectors are blocks that can be used for executing arbitrary pre-flight logic, such as modifying a request or logging data. Injectors are attached to an `HttpClient` using the `addInjector` method.\n\nThe `HttpClient` executes its injectors in a first-in, first-out order, before each request.\n\n```php\nclass LogInjector implements Injector\n{\n    public function inject($httpRequest)\n    {\n        // Do some logging here\n    }\n}\n\n$logInjector = new LogInjector();\n$client = new HttpClient($environment);\n$client-\u003eaddInjector($logInjector);\n...\n```\n\n### Error Handling\n\n`HttpClient#execute` may throw an `Exception` if something went wrong during the course of execution. If the server returned a non-200 response, [IOException](lib/PayPalHttp/IOException.php) will be thrown, that will contain a status code and headers you can use for debugging.\n\n```php\ntry\n{\n    $client-\u003eexecute($req);\n}\ncatch (HttpException $e)\n{\n    $statusCode = $e-\u003eresponse-\u003estatusCode;\n    $headers = $e-\u003eresponse-\u003eheaders;\n    $body = $e-\u003eresponse-\u003eresult;\n}\n```\n\n## License\nPayPalHttp-PHP is open source and available under the MIT license. See the [LICENSE](./LICENSE) file for more information.\n\n## Contributing\nPull requests and issues are welcome. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaypal%2Fpaypalhttp_php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaypal%2Fpaypalhttp_php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaypal%2Fpaypalhttp_php/lists"}