I’m trying to capture http request that occurs in a callback function :
// Code omitted
public function capture($fn)
{
// start http capture
$fn();
// end http capture and stores the capture in a variable
}
//example usage
$request->capture(function(){
do_some_http_request_with_curl_or_whatever_you_want();
});
I have tried various things with ob_start() and php wrappers… But nothing works, Help would be much appreciated !
Its impossible to capture any arbitrary HTTP request since the callback has lots of possible ways to go about it:
file_get_contents)Each of these approaches has (or does not have at all!) different ways of allowing you to hook into the mechanics of the request, so unless all mechanisms that you want to target support hooking and the callback actively cooperates with you, there’s no way to do this.