JSON API accents Restful [closed]

3

Good morning,

I'm creating an API for studying, but I'm having some issues with accents.

When I do a search, I have a response of not found.

Below is a test.

Would you have a solution for me to solve this situation?

Q: Using Slim Framework

    
asked by anonymous 15.05.2016 / 17:53

1 answer

0

When receiving the data in PHP use an encode to transfer the data to the variable:

header("Content-Type: text/html; charset=UTF-8",true);
$json = json_decode(file_get_contents('php://input',true));
$texto= utf8_encode($json->{"texto"});

and to return the data:

echo json_encode($response,JSON_UNESCAPED_UNICODE);

Make sure that the sent JSON is in UTF-8

    
17.06.2016 / 22:46