{"id":13462511,"url":"https://github.com/php-curl-class/php-curl-class","last_synced_at":"2025-05-13T20:03:05.009Z","repository":{"id":10102676,"uuid":"12165811","full_name":"php-curl-class/php-curl-class","owner":"php-curl-class","description":"PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs","archived":false,"fork":false,"pushed_at":"2025-03-31T18:33:32.000Z","size":2839,"stargazers_count":3287,"open_issues_count":5,"forks_count":820,"subscribers_count":160,"default_branch":"master","last_synced_at":"2025-05-06T19:51:53.021Z","etag":null,"topics":["api","api-client","class","client","curl","framework","http","http-client","http-proxy","json","php","php-curl","php-curl-library","proxy","requests","restful","web-scraper","web-scraping","web-service","xml"],"latest_commit_sha":null,"homepage":"https://www.phpcurlclass.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-curl-class.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-08-16T18:56:52.000Z","updated_at":"2025-05-01T15:19:38.000Z","dependencies_parsed_at":"2023-02-16T02:00:58.310Z","dependency_job_id":"775cab03-555d-46a5-9125-941220463298","html_url":"https://github.com/php-curl-class/php-curl-class","commit_stats":{"total_commits":1543,"total_committers":60,"mean_commits":"25.716666666666665","dds":"0.16331821127673363","last_synced_commit":"a041ac97db7145ab79d99692ae1d63c4c2e8bbb4"},"previous_names":[],"tags_count":112,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-curl-class%2Fphp-curl-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-curl-class%2Fphp-curl-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-curl-class%2Fphp-curl-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-curl-class%2Fphp-curl-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-curl-class","download_url":"https://codeload.github.com/php-curl-class/php-curl-class/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020471,"owners_count":22000749,"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":["api","api-client","class","client","curl","framework","http","http-client","http-proxy","json","php","php-curl","php-curl-library","proxy","requests","restful","web-scraper","web-scraping","web-service","xml"],"created_at":"2024-07-31T12:00:50.286Z","updated_at":"2025-05-13T20:03:04.949Z","avatar_url":"https://github.com/php-curl-class.png","language":"PHP","readme":"# PHP Curl Class: HTTP requests made easy\n\n[![](https://img.shields.io/github/release/php-curl-class/php-curl-class.svg?style=for-the-badge\u0026sort=semver)](https://github.com/php-curl-class/php-curl-class/releases/)\n[![](https://img.shields.io/github/license/php-curl-class/php-curl-class.svg?style=for-the-badge)](https://github.com/php-curl-class/php-curl-class/blob/master/LICENSE)\n[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/ci.yml?style=for-the-badge\u0026label=build\u0026branch=master)](https://github.com/php-curl-class/php-curl-class/actions/workflows/ci.yml)\n[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/release.yml?style=for-the-badge\u0026label=release\u0026branch=master)](https://github.com/php-curl-class/php-curl-class/releases/)\n[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/dependabot/dependabot-updates?style=for-the-badge\u0026label=Dependabot\u0026branch=master)](https://github.com/php-curl-class/php-curl-class/actions/workflows/dependabot/dependabot-updates)\n[![](https://img.shields.io/packagist/dt/php-curl-class/php-curl-class.svg?style=for-the-badge)](https://github.com/php-curl-class/php-curl-class/releases/)\n\nPHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.\n\n![PHP Curl Class screencast](www/img/screencast.gif)\n\n---\n\n- [⚙️ Installation](#%EF%B8%8F-installation)\n- [📋 Requirements](#-requirements)\n- [🚀 Quick Start and Examples](#-quick-start-and-examples)\n- [📖 Available Methods](#-available-methods)\n- [🔒 Security](#-security)\n- [🛠️ Troubleshooting](#%EF%B8%8F-troubleshooting)\n- [🧪 Testing](#-testing)\n- [🤝 Contributing](#-contributing)\n\n---\n\n### ⚙️ Installation\n\nTo install PHP Curl Class, run the following command:\n\n    composer require php-curl-class/php-curl-class\n\nTo install the latest commit version:\n\n    composer require php-curl-class/php-curl-class @dev\n\nInstallation instructions to use the `composer` command can be found on https://github.com/composer/composer.\n\n### 📋 Requirements\n\nPHP Curl Class works with PHP 8.4, 8.3, 8.2, 8.1, and 8.0.\n\n### 🚀 Quick Start and Examples\n\nMore examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples).\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Curl\\Curl;\n\n$curl = new Curl();\n$curl-\u003eget('https://www.example.com/');\n\nif ($curl-\u003eerror) {\n    echo 'Error: ' . $curl-\u003eerrorMessage . \"\\n\";\n    $curl-\u003ediagnose();\n} else {\n    echo 'Response:' . \"\\n\";\n    var_dump($curl-\u003eresponse);\n}\n```\n\n```php\n// https://www.example.com/search?q=keyword\n$curl = new Curl();\n$curl-\u003eget('https://www.example.com/search', [\n    'q' =\u003e 'keyword',\n]);\n```\n\n```php\n$curl = new Curl();\n$curl-\u003epost('https://www.example.com/login/', [\n    'username' =\u003e 'myusername',\n    'password' =\u003e 'mypassword',\n]);\n```\n\n```php\n$curl = new Curl();\n$curl-\u003esetBasicAuthentication('username', 'password');\n$curl-\u003esetUserAgent('MyUserAgent/0.0.1 (+https://www.example.com/bot.html)');\n$curl-\u003esetReferrer('https://www.example.com/url?url=https%3A%2F%2Fwww.example.com%2F');\n$curl-\u003esetHeader('X-Requested-With', 'XMLHttpRequest');\n$curl-\u003esetCookie('key', 'value');\n$curl-\u003eget('https://www.example.com/');\n\nif ($curl-\u003eerror) {\n    echo 'Error: ' . $curl-\u003eerrorMessage . \"\\n\";\n} else {\n    echo 'Response:' . \"\\n\";\n    var_dump($curl-\u003eresponse);\n}\n\nvar_dump($curl-\u003erequestHeaders);\nvar_dump($curl-\u003eresponseHeaders);\n```\n\n```php\n$curl = new Curl();\n$curl-\u003esetFollowLocation();\n$curl-\u003eget('https://shortn.example.com/bHbVsP');\n```\n\n```php\n$curl = new Curl();\n$curl-\u003eput('https://api.example.com/user/', [\n    'first_name' =\u003e 'Zach',\n    'last_name' =\u003e 'Borboa',\n]);\n```\n\n```php\n$curl = new Curl();\n$curl-\u003epatch('https://api.example.com/profile/', [\n    'image' =\u003e '@path/to/file.jpg',\n]);\n```\n\n```php\n$curl = new Curl();\n$curl-\u003epatch('https://api.example.com/profile/', [\n    'image' =\u003e new CURLFile('path/to/file.jpg'),\n]);\n```\n\n```php\n$curl = new Curl();\n$curl-\u003edelete('https://api.example.com/user/', [\n    'id' =\u003e '1234',\n]);\n```\n\n```php\n// Enable all supported encoding types and download a file.\n$curl = new Curl();\n$curl-\u003esetOpt(CURLOPT_ENCODING , '');\n$curl-\u003edownload('https://www.example.com/file.bin', '/tmp/myfile.bin');\n```\n\n```php\n// Case-insensitive access to headers.\n$curl = new Curl();\n$curl-\u003edownload('https://www.example.com/image.png', '/tmp/myimage.png');\necho $curl-\u003eresponseHeaders['Content-Type'] . \"\\n\"; // image/png\necho $curl-\u003eresponseHeaders['CoNTeNT-TyPE'] . \"\\n\"; // image/png\n```\n\n```php\n// Manual clean up.\n$curl-\u003eclose();\n```\n\n```php\n// Example access to curl object.\ncurl_set_opt($curl-\u003ecurl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1');\ncurl_close($curl-\u003ecurl);\n```\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Curl\\MultiCurl;\n\n// Requests in parallel with callback functions.\n$multi_curl = new MultiCurl();\n\n$multi_curl-\u003esuccess(function($instance) {\n    echo 'call to \"' . $instance-\u003eurl . '\" was successful.' . \"\\n\";\n    echo 'response:' . \"\\n\";\n    var_dump($instance-\u003eresponse);\n});\n$multi_curl-\u003eerror(function($instance) {\n    echo 'call to \"' . $instance-\u003eurl . '\" was unsuccessful.' . \"\\n\";\n    echo 'error code: ' . $instance-\u003eerrorCode . \"\\n\";\n    echo 'error message: ' . $instance-\u003eerrorMessage . \"\\n\";\n});\n$multi_curl-\u003ecomplete(function($instance) {\n    echo 'call completed' . \"\\n\";\n});\n\n$multi_curl-\u003eaddGet('https://www.google.com/search', [\n    'q' =\u003e 'hello world',\n]);\n$multi_curl-\u003eaddGet('https://duckduckgo.com/', [\n    'q' =\u003e 'hello world',\n]);\n$multi_curl-\u003eaddGet('https://www.bing.com/search', [\n    'q' =\u003e 'hello world',\n]);\n\n$multi_curl-\u003estart(); // Blocks until all items in the queue have been processed.\n```\n\nMore examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples).\n\n### 📖 Available Methods\n```php\nCurl::__construct($base_url = null, $options = [])\nCurl::__destruct()\nCurl::__get($name)\nCurl::__isset($name)\nCurl::afterSend($callback)\nCurl::attemptRetry()\nCurl::beforeSend($callback)\nCurl::buildPostData($data)\nCurl::call()\nCurl::close()\nCurl::complete($callback)\nCurl::delete($url, $query_parameters = [], $data = [])\nCurl::diagnose($return = false)\nCurl::disableTimeout()\nCurl::displayCurlOptionValue($option, $value = null)\nCurl::download($url, $mixed_filename)\nCurl::error($callback)\nCurl::exec($ch = null)\nCurl::execDone()\nCurl::fastDownload($url, $filename, $connections = 4)\nCurl::get($url, $data = [])\nCurl::getAttempts()\nCurl::getBeforeSendCallback()\nCurl::getCompleteCallback()\nCurl::getCookie($key)\nCurl::getCurl()\nCurl::getCurlErrorCode()\nCurl::getCurlErrorMessage()\nCurl::getDownloadCompleteCallback()\nCurl::getDownloadFileName()\nCurl::getErrorCallback()\nCurl::getErrorCode()\nCurl::getErrorMessage()\nCurl::getFileHandle()\nCurl::getHttpErrorMessage()\nCurl::getHttpStatusCode()\nCurl::getId()\nCurl::getInfo($opt = null)\nCurl::getJsonDecoder()\nCurl::getOpt($option)\nCurl::getOptions()\nCurl::getRawResponse()\nCurl::getRawResponseHeaders()\nCurl::getRemainingRetries()\nCurl::getRequestHeaders()\nCurl::getResponse()\nCurl::getResponseCookie($key)\nCurl::getResponseCookies()\nCurl::getResponseHeaders()\nCurl::getRetries()\nCurl::getRetryDecider()\nCurl::getSuccessCallback()\nCurl::getUrl()\nCurl::getUserSetOptions()\nCurl::getXmlDecoder()\nCurl::head($url, $data = [])\nCurl::isChildOfMultiCurl()\nCurl::isCurlError()\nCurl::isError()\nCurl::isHttpError()\nCurl::options($url, $data = [])\nCurl::patch($url, $data = [])\nCurl::post($url, $data = '', $follow_303_with_post = false)\nCurl::progress($callback)\nCurl::put($url, $data = [])\nCurl::removeHeader($key)\nCurl::reset()\nCurl::search($url, $data = [])\nCurl::setAutoReferer($auto_referer = true)\nCurl::setAutoReferrer($auto_referrer = true)\nCurl::setBasicAuthentication($username, $password = '')\nCurl::setConnectTimeout($seconds)\nCurl::setCookie($key, $value)\nCurl::setCookieFile($cookie_file)\nCurl::setCookieJar($cookie_jar)\nCurl::setCookieString($string)\nCurl::setCookies($cookies)\nCurl::setDefaultDecoder($mixed = 'json')\nCurl::setDefaultHeaderOut()\nCurl::setDefaultJsonDecoder()\nCurl::setDefaultTimeout()\nCurl::setDefaultUserAgent()\nCurl::setDefaultXmlDecoder()\nCurl::setDelete($url, $query_parameters = [], $data = [])\nCurl::setDigestAuthentication($username, $password = '')\nCurl::setFile($file)\nCurl::setFollowLocation($follow_location = true)\nCurl::setForbidReuse($forbid_reuse = true)\nCurl::setGet($url, $data = [])\nCurl::setHead($url, $data = [])\nCurl::setHeader($key, $value)\nCurl::setHeaders($headers)\nCurl::setInterface($interface)\nCurl::setJsonDecoder($mixed)\nCurl::setMaxFilesize($bytes)\nCurl::setMaximumRedirects($maximum_redirects)\nCurl::setOpt($option, $value)\nCurl::setOptions($url, $data = [])\nCurl::setOpts($options)\nCurl::setPatch($url, $data = [])\nCurl::setPort($port)\nCurl::setPost($url, $data = '', $follow_303_with_post = false)\nCurl::setProtocols($protocols)\nCurl::setProxy($proxy, $port = null, $username = null, $password = null)\nCurl::setProxyAuth($auth)\nCurl::setProxyTunnel($tunnel = true)\nCurl::setProxyType($type)\nCurl::setPut($url, $data = [])\nCurl::setRange($range)\nCurl::setRedirectProtocols($redirect_protocols)\nCurl::setReferer($referer)\nCurl::setReferrer($referrer)\nCurl::setRetry($mixed)\nCurl::setSearch($url, $data = [])\nCurl::setStop($callback = null)\nCurl::setTimeout($seconds)\nCurl::setUrl($url, $mixed_data = '')\nCurl::setUserAgent($user_agent)\nCurl::setXmlDecoder($mixed)\nCurl::stop()\nCurl::success($callback)\nCurl::unsetHeader($key)\nCurl::unsetProxy()\nCurl::verbose($on = true, $output = 'STDERR')\nMultiCurl::__construct($base_url = null)\nMultiCurl::__destruct()\nMultiCurl::addCurl(Curl $curl)\nMultiCurl::addDelete($url, $query_parameters = [], $data = [])\nMultiCurl::addDownload($url, $mixed_filename)\nMultiCurl::addGet($url, $data = [])\nMultiCurl::addHead($url, $data = [])\nMultiCurl::addOptions($url, $data = [])\nMultiCurl::addPatch($url, $data = [])\nMultiCurl::addPost($url, $data = '', $follow_303_with_post = false)\nMultiCurl::addPut($url, $data = [])\nMultiCurl::addSearch($url, $data = [])\nMultiCurl::afterSend($callback)\nMultiCurl::beforeSend($callback)\nMultiCurl::close()\nMultiCurl::complete($callback)\nMultiCurl::disableTimeout()\nMultiCurl::error($callback)\nMultiCurl::getActiveCurls()\nMultiCurl::getOpt($option)\nMultiCurl::removeHeader($key)\nMultiCurl::setAutoReferer($auto_referer = true)\nMultiCurl::setAutoReferrer($auto_referrer = true)\nMultiCurl::setBasicAuthentication($username, $password = '')\nMultiCurl::setConcurrency($concurrency)\nMultiCurl::setConnectTimeout($seconds)\nMultiCurl::setCookie($key, $value)\nMultiCurl::setCookieFile($cookie_file)\nMultiCurl::setCookieJar($cookie_jar)\nMultiCurl::setCookieString($string)\nMultiCurl::setCookies($cookies)\nMultiCurl::setDigestAuthentication($username, $password = '')\nMultiCurl::setFile($file)\nMultiCurl::setFollowLocation($follow_location = true)\nMultiCurl::setForbidReuse($forbid_reuse = true)\nMultiCurl::setHeader($key, $value)\nMultiCurl::setHeaders($headers)\nMultiCurl::setInterface($interface)\nMultiCurl::setJsonDecoder($mixed)\nMultiCurl::setMaximumRedirects($maximum_redirects)\nMultiCurl::setOpt($option, $value)\nMultiCurl::setOpts($options)\nMultiCurl::setPort($port)\nMultiCurl::setProxies($proxies)\nMultiCurl::setProxy($proxy, $port = null, $username = null, $password = null)\nMultiCurl::setProxyAuth($auth)\nMultiCurl::setProxyTunnel($tunnel = true)\nMultiCurl::setProxyType($type)\nMultiCurl::setRange($range)\nMultiCurl::setRateLimit($rate_limit)\nMultiCurl::setReferer($referer)\nMultiCurl::setReferrer($referrer)\nMultiCurl::setRequestTimeAccuracy()\nMultiCurl::setRetry($mixed)\nMultiCurl::setTimeout($seconds)\nMultiCurl::setUrl($url, $mixed_data = '')\nMultiCurl::setUserAgent($user_agent)\nMultiCurl::setXmlDecoder($mixed)\nMultiCurl::start()\nMultiCurl::stop()\nMultiCurl::success($callback)\nMultiCurl::unsetHeader($key)\nMultiCurl::unsetProxy()\nMultiCurl::verbose($on = true, $output = 'STDERR')\n```\n\n### 🔒 Security\n\nSee [SECURITY](https://github.com/php-curl-class/php-curl-class/blob/master/SECURITY.md) for security considerations.\n\n### 🛠️ Troubleshooting\n\nSee [TROUBLESHOOTING](https://github.com/php-curl-class/php-curl-class/blob/master/TROUBLESHOOTING.md) for help troubleshooting.\n\n### 🧪 Testing\n\nSee [TESTING](https://github.com/php-curl-class/php-curl-class/blob/master/TESTING.md) for testing information.\n\n### 🤝 Contributing\n\n1. Check for open issues or open a new issue to start a discussion around a bug or feature.\n1. Fork the repository on GitHub to start making your changes.\n1. Write one or more tests for the new feature or that expose the bug.\n1. Make code changes to implement the feature or fix the bug.\n1. Send a pull request to get your changes merged and published.\n","funding_links":[],"categories":["Uncategorized","超文本传输协议 HTTP","PHP","目录","HTTP","类库"],"sub_categories":["Uncategorized","HTTP客户端 HTTP Client","HTTP/网络通信"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-curl-class%2Fphp-curl-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-curl-class%2Fphp-curl-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-curl-class%2Fphp-curl-class/lists"}