{"id":19001724,"url":"https://github.com/ledccn/curl","last_synced_at":"2025-09-18T00:11:12.301Z","repository":{"id":186620239,"uuid":"675467463","full_name":"ledccn/curl","owner":"ledccn","description":"基于Curl扩展的请求类库","archived":false,"fork":false,"pushed_at":"2025-09-15T10:05:37.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T16:37:41.672Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ledccn.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":"2023-08-07T01:59:53.000Z","updated_at":"2025-09-15T10:05:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"c80d6808-6655-474a-9291-d75bdea4b961","html_url":"https://github.com/ledccn/curl","commit_stats":null,"previous_names":["ledccn/curl"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/ledccn/curl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fcurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fcurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fcurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fcurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ledccn","download_url":"https://codeload.github.com/ledccn/curl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fcurl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275680444,"owners_count":25508570,"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","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08T18:12:27.764Z","updated_at":"2025-09-18T00:11:12.248Z","avatar_url":"https://github.com/ledccn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Curl Class\n\nThis library provides an object-oriented and dependency free wrapper of the PHP cURL extension.\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/6c34bb31f3eb6df36c7d/maintainability)](https://codeclimate.com/github/php-mod/curl/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/6c34bb31f3eb6df36c7d/test_coverage)](https://codeclimate.com/github/php-mod/curl/test_coverage)\n[![Total Downloads](https://poser.pugx.org/curl/curl/downloads)](//packagist.org/packages/curl/curl)\n[![Tests](https://github.com/php-mod/curl/actions/workflows/tests.yml/badge.svg)](https://github.com/php-mod/curl/actions/workflows/tests.yml)\n\nIf you have questions or problems with installation or usage [create an Issue](https://github.com/php-mod/curl/issues).\n\n## Installation\n\nIn order to install this library via composer run the following command in the console:\n\n```sh\ncomposer require ledc/curl\n```\n\n## Usage examples\n\nA few example for using CURL with get:\n\n```php\nuse Ledc\\Curl\\Curl;\n\n$curl = (new Curl())-\u003eget('http://www.example.com/');\nif ($curl-\u003eisSuccess()) {\n    // do something with response\n    var_dump($curl-\u003eresponse);\n}\n// ensure to close the curl connection\n$curl-\u003eclose();\n```\n\nupload file metadata\n\n```php\nuse Ledc\\Curl\\Curl;\n\n$curl = new Curl();\n$json = '[{\"length\":7533293969,\"path\":[\"Brotherhood.of.the.Wolf.2001.BluRay.1080p.x265.10bit.2Audio.mkv\"]},{\"length\":958431,\"path\":[\"cover.jpg\"]},{\"length\":760,\"path\":[\"Brotherhood.of.the.Wolf.2001.BluRay.1080p.x265.10bit.2Audio.nfo\"]}]';\n$curl-\u003eaddFile('file', '1.json', $json, 'application/json');\n$curl-\u003eupload('http://www.example.com/upload');\n$response = $curl-\u003eresponse;\nprintf($response);\n```\n\nOr with params, values will be encoded with `PHP_QUERY_RFC1738`:\n\n```php\nuse Ledc\\Curl\\Curl;\n$curl = (new Curl())-\u003eget('http://www.example.com/search', [\n    'q' =\u003e 'keyword',\n]);\n```\n\nAn example using post\n\n```php\nuse Ledc\\Curl\\Curl;\n$curl = new Curl();\n$curl-\u003epost('http://www.example.com/login/', [\n    'username' =\u003e 'myusername',\n    'password' =\u003e 'mypassword',\n]);\n```\n\nAn exampling using basic authentication, remove default user agent and working with error handling\n\n```php\nuse Ledc\\Curl\\Curl;\n$curl = new Curl();\n$curl-\u003esetBasicAuthentication('username', 'password');\n$curl-\u003esetUserAgent('');\n$curl-\u003esetHeader('X-Requested-With', 'XMLHttpRequest');\n$curl-\u003esetCookie('key', 'value');\n$curl-\u003eget('http://www.example.com/');\n\nif ($curl-\u003eerror) {\n    echo $curl-\u003eerror_code;\n} else {\n    echo $curl-\u003eresponse;\n}\n\nvar_dump($curl-\u003erequest_headers);\nvar_dump($curl-\u003eresponse_headers);\n```\n\nSSL verification setup:\n\n```php\nuse Ledc\\Curl\\Curl;\n$curl = new Curl();\n$curl-\u003esetOpt(CURLOPT_RETURNTRANSFER, TRUE);\n$curl-\u003esetOpt(CURLOPT_SSL_VERIFYPEER, FALSE);\n$curl-\u003eget('https://encrypted.example.com/');\n```\n\nExample access to curl object:\n\n```php\ncurl_set_opt($curl-\u003ecurl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1');\ncurl_close($curl-\u003ecurl);\n```\n\nExample of downloading a file or any other content\n\n```php\nuse Ledc\\Curl\\Curl;\n$curl = new Curl();\n// open the file where the request response should be written\n$file_handle = fopen($target_file, 'w+');\n// pass it to the curl resource\n$curl-\u003esetOpt(CURLOPT_FILE, $file_handle);\n// do any type of request\n$curl-\u003eget('https://github.com');\n// disable writing to file\n$curl-\u003esetOpt(CURLOPT_FILE, null);\n// close the file for writing\nfclose($file_handle);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledccn%2Fcurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fledccn%2Fcurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledccn%2Fcurl/lists"}