another one curls the dust
Array
(
[curler_info] => Loads the content of a JSON file and executes some callback functions in a row (7 to be specific)
[curler] => Array
(
[url] => https://raw.githubusercontent.com/eypsilon/Curler/master/www.example.json
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => text/plain; charset=utf-8
[meta] => disabled
[error] =>
[response] => {
"Many": "App",
"example": "json file",
"custom_callback": [
"custom_callback done, 08:58:36.2317"
],
"callback_two": [
"callback_two done, 08:58:36.2317"
],
"callback_three": [
"callback_three done, 08:58:36.2317"
],
"callback_class_run": [
"callback_class_run done, 08:58:36.2317"
],
"callback_class_init": [
"callback_class_init done, 08:58:36.2317",
"callback_class_init done, 08:58:36.2317"
],
"closure_callback": [
"closure_callback done, 08:58:36.2317"
],
"done_too": [
"done_too done, 08:58:36.2318"
]
}
)
[load_urls_info] => Loads a handful of URLs and truncates the response
[load_urls] => Array
(
[0] => Array
(
[url] => http://example.com/
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => text/html
[meta] => disabled
[error] =>
[response] => <!doctype html>… 2025-10-26 08:58:36.2318
)
[1] => Array
(
[url] => https://raw.githubusercontent.com/eypsilon/browser-reload/master/LICENSE
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => text/plain; charset=utf-8
[meta] => disabled
[error] =>
[response] => The MIT License (MIT… 2025-10-26 08:58:36.2461
)
[2] => Array
(
[url] => https://github.com/eypsilon/MycroBench
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => text/html; charset=utf-8
[meta] => disabled
[error] =>
[response] => <!DOCTYPE html>… 2025-10-26 08:58:36.2716
)
)
[loaded_images_info] => The images displayed above, the responses are truncated
[loaded_images] => Array
(
[0] => Array
(
[url] => https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Andaman.jpg/200px-Andaman.jpg
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => image/jpeg
[meta] => Array
(
[scheme] => HTTPS
[size] => 6.81 KB
[datetime] => 2025-10-26 08:58:36.3382
)
[error] =>
[response] => data:image/jpeg;base64,/9j/2wBDAAQD …
)
[1] => Array
(
[url] => https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Aurora_and_sunset.jpg/200px-Aurora_and_sunset.jpg
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => image/jpeg
[meta] => Array
(
[scheme] => HTTPS
[size] => 5.81 KB
[datetime] => 2025-10-26 08:58:36.3727
)
[error] =>
[response] => data:image/jpeg;base64,/9j/4QCGRXhp …
)
[2] => Array
(
[url] => https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Sunset_at_Egipura%2C_Bangalore.jpg/200px-Sunset_at_Egipura%2C_Bangalore.jpg
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => image/jpeg
[meta] => Array
(
[scheme] => HTTPS
[size] => 10.23 KB
[datetime] => 2025-10-26 08:58:36.4078
)
[error] =>
[response] => data:image/jpeg;base64,/9j/2wBDAAQD …
)
[3] => Array
(
[url] => https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/After_The_Storm_(3594761019).jpg/200px-After_The_Storm_(3594761019).jpg
[http_code] => 200
[status] => ok
[method] => GET
[content_type] => image/jpeg
[meta] => Array
(
[scheme] => HTTPS
[size] => 9.27 KB
[datetime] => 2025-10-26 08:58:36.4354
)
[error] =>
[response] => data:image/jpeg;base64,/9j/2wBDAAQD …
)
)
[getCurlCount] => 8
[getCurlTrace] => Array
(
[01__2025-10-26 08:58:36.2298] => GET 200 https://raw.githubusercontent.com/eypsilon/Curler/master/www.example.json
[02__2025-10-26 08:58:36.2459] => GET 200 http://example.com/
[03__2025-10-26 08:58:36.2698] => GET 200 https://raw.githubusercontent.com/eypsilon/browser-reload/master/LICENSE
[04__2025-10-26 08:58:36.3041] => GET 200 https://github.com/eypsilon/MycroBench
[05__2025-10-26 08:58:36.3383] => GET 200 {replaced_url} …/8/80/Andaman.jpg/200px-Andaman.jpg
[06__2025-10-26 08:58:36.3728] => GET 200 {replaced_url} …/2/21/Aurora_and_sunset.jpg/200px-Aurora_and_sunset.jpg
[07__2025-10-26 08:58:36.4079] => GET 200 {replaced_url} …/9/93/Sunset_at_Egipura%2C_Bangalore.jpg/200px-Sunset_at_Egipura%2C_Bangalore.jpg
[08__2025-10-26 08:58:36.4355] => GET 200 {replaced_url} …/3/3e/After_The_Storm_(3594761019).jpg/200px-After_The_Storm_(3594761019).jpg
)
[getConfig] => Array
(
[response_only] =>
[curl_trace] => 1
[exceptions] => 1
[meta] => 1
[request_info] =>
[curl_info] =>
[default_url] => https://upload.wikimedia.org/wikipedia/commons/thumb
[date_format] => Y-m-d H:i:s.u
[image_to_data] => Array
(
[0] => image/jpeg
)
[default_header] => Array
(
[x-app-curler] => Many/Curler
[Content-Type] => application/json
)
[default_options] => Array
(
[10018] => AwesomeUser
)
[default_callback] => Array
(
)
)
[getOptions] => Array
(
[CURLOPT_HTTP_VERSION] => 0
[CURLOPT_URL] =>
[CURLOPT_CUSTOMREQUEST] => GET
[CURLOPT_HEADER] =>
[CURLOPT_HTTPHEADER] => Array
(
[0] => x-app-curler: Many/Curler
[1] => Content-Type: application/json
)
[2] =>
[CURLOPT_POST] =>
[CURLOPT_POSTFIELDS] =>
[CURLOPT_SSL_VERIFYHOST] => 2
[CURLOPT_SSL_VERIFYPEER] => 1
[CURLOPT_RETURNTRANSFER] => 1
[CURLOPT_VERBOSE] => 1
[CURLOPT_AUTOREFERER] => 1
[CURLOPT_FOLLOWLOCATION] => 1
[CURLOPT_MAXREDIRS] => 10
[CURLOPT_CONNECTTIMEOUT] => 90
[CURLOPT_TIMEOUT] => 90
[CURLOPT_ACCEPT_ENCODING] => gzip
[CURLOPT_USERAGENT] => AwesomeUser
)
)
<?php
/**
* Curler Responder, let's say 'https://example.com/restricted/' is .htaccess protected and returns
*/
use Many\Http\Curler;
$rspns = [
'auth_type' => $_SERVER['AUTH_TYPE'] ?? 'error',
'header' => getallheaders(),
'body' => file_get_contents('php://input'),
'c_types' => [
'json' => 'application/json',
]
];
$setType = $rspns['c_types'][$_GET['c_type'] ?? null] ?? null;
$cType = $setType ?? $_SERVER['CONTENT_TYPE'] ?? 'text/html';
/** Set Content-Type header auto, if requested one is listed in 'c_types' */
if ($setType)
header(sprintf('Content-Type: %s; charset: %s', $cType, $_GET['charset'] ?? 'UTF-8'));
/** Parse received body content */
if (ctype_print($rspns['body']))
parse_str($rspns['body'], $rspns['body_parsed']);
exit('application/json' == $cType
? json_encode($rspns, JSON_PRETTY_PRINT)
: print_r($rspns, true)
);
/**
* Curler Receiver, access the .htaccess protected ressources
*/
$curler = (new Curler)
->authAny('many', '123456') // auto ->authBasic() or ->authDigest()
->postFields([
'lorem_ipsum' => 'Dolor Sit Amet',
])
->jsonDecode()
->exec('https://example.com/restricted/'); // ?c_type=json &charset=UTF-8
printf('<pre>%s<hr /><b>body</b><br />%s</pre>'
, print_r($curler, true)
, $curler['response']->body ?? 'body is not an object'
);
start: 08:58:36.2100 end: 08:58:36.4382 diff: 0.2282 mem: 432.37 KB peak: 1.47 MB