I created a Bundle that calls an third party api.
Now i want to show the received data in the Symfony Profiler.
I created a CustomDataCollector (http://symfony.com/doc/current/profiler/data_collector.html). That all works fine. But how can i get or "save" the received response for the api?
I created a service that calls the api with curl like that:
$raw_response = curl_exec($ch);
    $response = json_decode($raw_response);
    if (property_exists($response, 'error') && $response->errors) {
        return ['status'=>false, 'msg'=> (string)$response->errors[0]->description ] ;
    } else {
        return ['status'=>true, 'msg' =>'Send Successfully' ];
    }
I'd advise you to use the logger service for simple use-cases that don't require a specific collector. You can provide additional context to the logging:
/** LoggerInterface */
$container->get('logger')->error('There was an error on the API call.', array(
    'description' => $response->errors[0]->description
);
The logger data is saved to a profile by default. For more advanced use cases you might be looking for the processors: http://symfony.com/doc/current/logging/processors.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With