I thank you in advance for taking time to read my problem that I face. The execution of a Rest Full API (https://dusupay.com/transactions/check_status/1386/19892016.json) from a browser returns me from json.
Now I need to retrieve the data returned by this API in a controller, but unfortunately, it returns me earlier "text / HTML"
use Zeroem\CurlBundle\HttpKernel\RemoteHttpKernel
$request = Request::create("https://dusupay.com/transactions/check_status/1386/19892016.json");
$remoteKernel = new RemoteHttpKernel();
$response1 = $remoteKernel->handle($request);
return new response ($response1);
When i try to change the content type in JSON, I receive nothing more as an answer.
Thanks for the time
Use JsonResponse instead of Response:
use Symfony\Component\HttpFoundation\JsonResponse;
You can controll all responses formats for your API by Symfony Format Listener. Check this out: https://symfony.com/doc/current/bundles/FOSRestBundle/3-listener-support.html
Or for some particular route use just simple:
return new JsonResponse($response);
After some modifications, the problem was solved
use Zeroem\CurlBundle\HttpKernel\RemoteHttpKernel;
$request = Request::create("https://dusupay.com/transactions/check_status/1386/19892016.json");
$remoteKernel = new RemoteHttpKernel();
$response1 = $remoteKernel->handle($request);
$data = json_decode($response1->getContent());
return new response($data->Response->customer_email);