{"id":35159345,"url":"https://github.com/a19836/php-curl-lib","last_synced_at":"2026-04-22T08:31:44.787Z","repository":{"id":329261657,"uuid":"1118308282","full_name":"a19836/php-curl-lib","owner":"a19836","description":"PHP Curl Lib is a library that simplifies making HTTP requests using the cURL extension. It provides a clean, object-oriented API to perform GET, POST, PUT, DELETE, and other HTTP requests, handle headers, query parameters, and manage responses efficiently.","archived":false,"fork":false,"pushed_at":"2025-12-18T19:18:10.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-21T17:30:55.372Z","etag":null,"topics":["api-client","api-integration","curl","curl-api","curl-framework","curl-get","curl-post","curl-put","http-client","http-communication","http-request","http-tools","json-api","php","remote-request","requests","rest","rest-client","web-requests","web-services"],"latest_commit_sha":null,"homepage":"https://www.bloxtor.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a19836.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-17T15:04:14.000Z","updated_at":"2025-12-18T19:18:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/a19836/php-curl-lib","commit_stats":null,"previous_names":["a19836/phpcurllib"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/a19836/php-curl-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a19836%2Fphp-curl-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a19836%2Fphp-curl-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a19836%2Fphp-curl-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a19836%2Fphp-curl-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a19836","download_url":"https://codeload.github.com/a19836/php-curl-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a19836%2Fphp-curl-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32127848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T07:37:52.372Z","status":"ssl_error","status_checked_at":"2026-04-22T07:37:51.635Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api-client","api-integration","curl","curl-api","curl-framework","curl-get","curl-post","curl-put","http-client","http-communication","http-request","http-tools","json-api","php","remote-request","requests","rest","rest-client","web-requests","web-services"],"created_at":"2025-12-28T17:52:17.939Z","updated_at":"2026-04-22T08:31:44.783Z","avatar_url":"https://github.com/a19836.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Curl Lib\n\n\u003e Original Repos:   \n\u003e - PHP Curl Lib: https://github.com/a19836/php-curl-lib/   \n\u003e - Bloxtor: https://github.com/a19836/bloxtor/\n\n## Overview\n\n**PHP Curl Lib** is a library that simplifies making HTTP requests using the cURL extension.  \nIt provides a clean, object-oriented API to perform GET, POST, PUT, DELETE, and other HTTP requests, handle headers, query parameters, and manage responses efficiently.   \n\nThe library allows you to:   \n- Send HTTP requests to any URL with full control over method, headers, and payload\n- Handle GET, POST, PUT, DELETE, PATCH, and custom HTTP methods\n- Manage request headers, cookies, and query parameters easily\n- Send JSON, form-data, or raw body content\n- Receive and parse responses, including headers and status codes\n- Handle timeouts, redirects, and SSL verification\n- Support synchronous and asynchronous requests (if implemented)\n- Simplify error handling and logging of requests/responses\n\nThis library is ideal for integrating with APIs, web services, and performing server-to-server communication in a reliable and reusable way.   \n\nTo see a working example, open [index.php](index.php) on your server.\n\n---\n\n## Usage\n\n### Get url contents\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n$html = MyCurl::getUrlContents(array(\"url\" =\u003e \"https://bloxtor.com\"), \"content\");\n```\n\n### Download File\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n$downloaded_file_pointer = null; //optional\n$downloaded_file_info = MyCurl::downloadFile($file_url, $downloaded_file_pointer);\n```\n\n### Get single url header\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n//set url single data. The only mandatory configuration is the key: \"url\"!\n$single_data = array(\n\t\"url\" =\u003e $url, \n\t\"post\" =\u003e array(\n\t\t\"ab\" =\u003e $ab,\n\t\t\"st\" =\u003e array(\"activity\")\n\t),\n\t\"cookie\" =\u003e $_COOKIE,\n\t\"settings\" =\u003e array(\n\t\t\"follow_location\" =\u003e 1,\n\t\t\"connection_timeout\" =\u003e 10,\n\t\t\"header\" =\u003e 1,\n\t\t\"no_body\" =\u003e true,\n\t\t\"http_auth\" =\u003e !empty($_SERVER[\"AUTH_TYPE\"]) ? $_SERVER[\"AUTH_TYPE\"] : null,\n\t\t\"user_pwd\" =\u003e !empty($_SERVER[\"PHP_AUTH_USER\"]) ? $_SERVER[\"PHP_AUTH_USER\"] . \":\" . (isset($_SERVER[\"PHP_AUTH_PW\"]) ? $_SERVER[\"PHP_AUTH_PW\"] : \"\") : null,\n\t)\n);\n\n//set the returned type\n$result_type = \"header\"; //available values: \"settings\", \"header\", \"content\", \"content_json\", \"content_xml\", \"content_xml_simple\", \"content_serialized\"\n\n//fetch url\n$header = MyCurl::getUrlContents($single_data, $result_type);\n\n//print url header\necho $header;\n```\n\n### Get single url data - settings, header and html\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n//set url single data. The only mandatory configuration is the key: \"url\"!\n$single_data = array(\n\t\"url\" =\u003e $url, //string with url to fetch\n\t\"post\" =\u003e $post, //query string or associative array with key-value pair list.\n\t\"get\" =\u003e $get, //query string or associative array with key-value pair list.\n\t\"cookie\" =\u003e $cookie, //cookies string or associative array with key-value pair list.\n\t\"files\" =\u003e array(\n\t\t\"file name to display\" =\u003e array(\n\t\t\t\"tmp_name\" =\u003e \"file path\", \n\t\t\t\"name\" =\u003e \"original file name\", \n\t\t\t\"type\" =\u003e \"file content type\"\n\t\t)\n\t),\n\t\"settings\" =\u003e array(\n\t\t\"put\" =\u003e true, //Set to true to HTTP PUT a file.\n\t\t\"header\" =\u003e true, //Set to true to include the headers in the output\n\t\t\"connection_timeout\" =\u003e 60, //in seconds\n\t\t\"no_body\" =\u003e false, //Set to true to exclude the body from the output\n\t\t\"http_header\" =\u003e array('Content-type: text/plain', 'Content-length: 100'), //An array of HTTP header fields to set, in the format \n\t\t\"referer\" =\u003e \"\", //A string with the contents of the Referer\n\t\t\"follow_location\" =\u003e true,\n\t\t\"http_auth\" =\u003e \"basic\", //Available values: \"\", \"basic\", \"digest\", CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLAUTH_ANY, CURLAUTH_ANYSAFE\n\t\t\"user_pwd\" =\u003e \"test:test\", //A username and password formatted as [username]:[password] to use for the connection.\n\t\t\"read_cookies_from_file\" =\u003e \"\", //A string with the name of the file containing the cookie data. The cookie file can be in Netscape format, or just plain HTTP-style headers dumped into a file.\n\t\t\"save_cookies_to_file\" =\u003e \"\", //A string with the name of a file to save all internal cookies to when the handle's destructor is called.\n\t\t\n\t\t//Add also other settings to your CURL based in available curl options defined at: https://www.php.net/manual/en/curl.constants.php#constant.curlopt-abstract-unix-socket. The key setting must start with 'CURLOPT_'\n\t\t//\"CURLOPT_XXX\" =\u003e \"...\",\n\t)\n);\n\n//fetch url\n$MyCurl = new MyCurl();\n$MyCurl-\u003einitSingle($single_data);\n$MyCurl-\u003eget_contents($async = false); //fetch urls sequentially\n$data = $MyCurl-\u003egetData();\n$data = isset($data[0]) ? $data[0] : null;\n\n//print url data\necho \"\u003cpre\u003e\" . print_r($data) . \"\u003c/pre\u003e\";\n```\n\n### Get data from group of urls with same configurations\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n//set urls group data. The only mandatory configuration is the key: \"urls\"!\n$group_data = array(\n\t\"urls\" =\u003e array(\"https://bloxtor.com\", \"https://bloxtor.com/framework\", \"https://bloxtor.com/pricing\"), \n\t\"cookie\" =\u003e $_COOKIE,\n\t\"settings\" =\u003e array(\n\t\t\"follow_location\" =\u003e 1,\n\t\t\"connection_timeout\" =\u003e 10,\n\t)\n);\n\n//fetch urls\n$MyCurl = new MyCurl();\n$MyCurl-\u003einitSingleGroup($group_data); //init all urls with the same configurations\n$MyCurl-\u003eget_contents($async = false); //fetch urls sequentially\n$data = $MyCurl-\u003egetData();\n\n//print all urls data\necho \"\u003cpre\u003e\" . print_r($data) . \"\u003c/pre\u003e\";\n```\n\n### Get multiple urls with different configurations\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n//set multiple urls data. The only mandatory configuration is the key: \"url\" for each array item!\n$multiple_data = array(\n\tarray(\n\t\t\"url\" =\u003e \"http://url_1.com\",\n\t\t\"post\" =\u003e array(\"a\" =\u003e \"b\"),\n\t),\n\tarray(\n\t\t\"url\" =\u003e \"http://url_2.com\",\n\t\t\"cookie\" =\u003e $cookie,\n\t),\n\tarray(\n\t\t\"url\" =\u003e \"http://url_3.com\",\n\t\t\"settings\" =\u003e array(\n\t\t\t\"connection_timeout\" =\u003e 10,\n\t\t\t//...\n\t\t),\n\t\t//...\n\t),\n\t//...\n);\n\n//fetch urls\n$MyCurl = new MyCurl();\n$MyCurl-\u003einitMultiple($multiple_data);\n$MyCurl-\u003eget_contents($async = false); //fetch urls sequentially\n$data = $MyCurl-\u003egetData();\n\n//print all urls data\necho \"\u003cpre\u003e\" . print_r($data) . \"\u003c/pre\u003e\";\n```\n\n### Get urls asynchronously\n\n```php\ninclude __DIR__ . \"/lib/MyCurl.php\";\n\n//set urls group data.\n$group_data = array(\n\t\"urls\" =\u003e array(\"https://bloxtor.com\", \"https://bloxtor.com/framework\", \"https://bloxtor.com/pricing\"), \n);\n\n//fetch urls\n$MyCurl = new MyCurl();\n$MyCurl-\u003einitSingleGroup($group_data); //init all urls with the same configurations\n$MyCurl-\u003eget_contents($async = true); //fetch urls all at once - asynchronously\n$data = $MyCurl-\u003egetData();\n\n//print all urls data\necho \"\u003cpre\u003e\" . print_r($data) . \"\u003c/pre\u003e\";\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa19836%2Fphp-curl-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa19836%2Fphp-curl-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa19836%2Fphp-curl-lib/lists"}