Ben daha sonra bir dizi içinde saklar (RollingCurl ile) ve end çıkışları o JSON biçiminde anda birden fazla sitelerinden (in parallel) http yanıt başlıklarını kapmak bir web uygulaması yazıyorum.
Since some sites do redirects to new locations, $info (array) in “request_callback” function always contains an url ($info[‘url’]) where the requested url was redirected to, and it’s quite expected. But how to push a requested url into array (@ $info[‘requested_url’]) to know which $info (response data) is associated with its requested url?
$urls = array(
"http://google.com",
"http://microsoft.com"
// more urls here
);
$json = array();
$rc = new RollingCurl("request_callback");
$rc->window_size = 20;
foreach ($urls as $url) {
$request = new Request($url);
$rc->add($request);
}
$rc->execute();
echo json_encode($json);
exit;
function request_callback($response, $info) {
global $json;
$json['status'][] = $info;
}
Den / / fragmanı RollingCurl.php:
// send the return values to the callback function.
$callback = $this->callback;
if (is_callable($callback)){
$info[‘requested_url’] = **???** // How to get a requested url & push it into $info?
call_user_func($callback, $output, $info);
}