{"id":13462307,"url":"https://github.com/shuber/curl","last_synced_at":"2025-04-05T04:13:15.508Z","repository":{"id":397160,"uuid":"15231","full_name":"shuber/curl","owner":"shuber","description":"A basic CURL wrapper for PHP","archived":false,"fork":false,"pushed_at":"2022-04-27T00:25:59.000Z","size":484,"stargazers_count":468,"open_issues_count":14,"forks_count":178,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-03-29T03:09:05.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"twbs/bootstrap-sass","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuber.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-05-07T18:05:24.000Z","updated_at":"2025-03-05T17:00:13.000Z","dependencies_parsed_at":"2022-07-07T15:11:19.042Z","dependency_job_id":null,"html_url":"https://github.com/shuber/curl","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/shuber%2Fcurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fcurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fcurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fcurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuber","download_url":"https://codeload.github.com/shuber/curl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284951,"owners_count":20913704,"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-07-31T12:00:44.312Z","updated_at":"2025-04-05T04:13:15.482Z","avatar_url":"https://github.com/shuber.png","language":"PHP","readme":"# curl\n\nA basic CURL wrapper for PHP (see [http://php.net/curl](http://php.net/curl) for more information about the libcurl extension for PHP)\n\n\n## Installation\n\nClick the `download` link above or `git clone git://github.com/shuber/curl.git`\n\n\n## Usage\n\n### Initialization\n\nSimply require and initialize the `Curl` class like so:\n\n\trequire_once 'curl.php';\n\t$curl = new Curl;\n\n\n### Performing a Request\n\nThe Curl object supports 5 types of requests: HEAD, GET, POST, PUT, and DELETE. You must specify a url to request and optionally specify an associative array or string of variables to send along with it.\n\n\t$response = $curl-\u003ehead($url, $vars = array());\n\t$response = $curl-\u003eget($url, $vars = array()); # The Curl object will append the array of $vars to the $url as a query string\n\t$response = $curl-\u003epost($url, $vars = array());\n\t$response = $curl-\u003eput($url, $vars = array());\n\t$response = $curl-\u003edelete($url, $vars = array());\n\nTo use a custom request methods, you can call the `request` method:\n\n\t$response = $curl-\u003erequest('YOUR_CUSTOM_REQUEST_TYPE', $url, $vars = array());\n\nAll of the built in request methods like `put` and `get` simply wrap the `request` method. For example, the `post` method is implemented like:\n\n\tfunction post($url, $vars = array()) {\n\t    return $this-\u003erequest('POST', $url, $vars);\n\t}\n\nExamples:\n\n\t$response = $curl-\u003eget('google.com?q=test');\n\n\t# The Curl object will append '\u0026some_variable=some_value' to the url\n\t$response = $curl-\u003eget('google.com?q=test', array('some_variable' =\u003e 'some_value'));\n\t\n\t$response = $curl-\u003epost('test.com/posts', array('title' =\u003e 'Test', 'body' =\u003e 'This is a test'));\n\nAll requests return a CurlResponse object (see below) or false if an error occurred. You can access the error string with the `$curl-\u003eerror()` method.\n\n\n### The CurlResponse Object\n\nA normal CURL request will return the headers and the body in one response string. This class parses the two and places them into separate properties.\n\nFor example\n\n\t$response = $curl-\u003eget('google.com');\n\techo $response-\u003ebody; # A string containing everything in the response except for the headers\n\tprint_r($response-\u003eheaders); # An associative array containing the response headers\n\nWhich would display something like\n\n\t\u003chtml\u003e\n\t\u003chead\u003e\n\t\u003ctitle\u003eGoogle.com\u003c/title\u003e\n\t\u003c/head\u003e\n\t\u003cbody\u003e\n\tSome more html...\n\t\u003c/body\u003e\n\t\u003c/html\u003e\n\n\tArray\n\t(\n\t    [Http-Version] =\u003e 1.0\n\t    [Status-Code] =\u003e 200\n\t    [Status] =\u003e 200 OK\n\t    [Cache-Control] =\u003e private\n\t    [Content-Type] =\u003e text/html; charset=ISO-8859-1\n\t    [Date] =\u003e Wed, 07 May 2008 21:43:48 GMT\n\t    [Server] =\u003e gws\n\t    [Connection] =\u003e close\n\t)\n\t\nThe CurlResponse class defines the magic [__toString()](http://php.net/__toString) method which will return the response body, so `echo $response` is the same as `echo $response-\u003ebody`\n\n\n### Cookie Sessions\n\nBy default, cookies will be stored in a file called `curl_cookie.txt`. You can change this file's name by setting it like this\n\n\t$curl-\u003ecookie_file = 'some_other_filename';\n\nThis allows you to maintain a session across requests\n\n\n### Basic Configuration Options\n\nYou can easily set the referer or user-agent\n\n\t$curl-\u003ereferer = 'http://google.com';\n\t$curl-\u003euser_agent = 'some user agent string';\n\nYou may even set these headers manually if you wish (see below)\n\n\n### Setting Custom Headers\n\nYou can set custom headers to send with the request\n\n\t$curl-\u003eheaders['Host'] = 12.345.678.90;\n\t$curl-\u003eheaders['Some-Custom-Header'] = 'Some Custom Value';\n\n\n### Setting Custom CURL request options\n\nBy default, the `Curl` object will follow redirects. You can disable this by setting:\n\n\t$curl-\u003efollow_redirects = false;\n\nYou can set/override many different options for CURL requests (see the [curl_setopt documentation](http://php.net/curl_setopt) for a list of them)\n\n\t# any of these will work\n\t$curl-\u003eoptions['AUTOREFERER'] = true;\n\t$curl-\u003eoptions['autoreferer'] = true;\n\t$curl-\u003eoptions['CURLOPT_AUTOREFERER'] = true;\n\t$curl-\u003eoptions['curlopt_autoreferer'] = true;\n\n\n## Testing\n\nUses [ztest](http://github.com/jaz303/ztest), simply download it to `path/to/curl/test/ztest` (or anywhere else in your php include_path)\n\nThen run `test/runner.php`\n\n\n## Contact\n\nProblems, comments, and suggestions all welcome: [shuber@huberry.com](mailto:shuber@huberry.com)","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuber%2Fcurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuber%2Fcurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuber%2Fcurl/lists"}