It can be an anonymous function:
$rc = new RollingCurl();
$rc->setCallback(function($request, $rolling_curl) {
process
});
Or an existing function:
class MyClass {
function doCurl() {
$rc = new RollingCurl();
$rc->setCallback(array($this, 'callback'));
}
Cannot be private or protected
public function callback($request, $rolling_curl) {
process
}
}
The called code should expect two parameters: \RollingCurl\Request $request, \RollingCurl\RollingCurl $rollingCurl
$request is original request object, but now with body, headers, response code, etc
$rollingCurl is the rolling curl object itself (useful if you want to re/queue a URL)
public setCallback ( callable $callback ) : |
||
$callback | callable | |
Результат |