F
F
Funny_Cat2021-06-25 12:28:15
PHP
Funny_Cat, 2021-06-25 12:28:15

How to get readable characters when using PHP webhooks?

In general, I work with webhooks with a third-party resource. In response, I get unreadable characters. The developers of that resource claim that they send data in UTF-8 encoding. However, I am getting unreadable characters (where Cyrillic should be). For example:

{"id":10,"customerPhone":"79999999999","totalSum":100.0,"positions":[{"sum":100.0,"totalSum":100.0,"qnt":2.0,"product":"40e620ff-5788-4723-9ab7-ad90f545c342","discount":19.5,"bonusDebit":0.0,"bonusCredit":15.0,"cat":"???????","price":195.0}]}


What only translation methods in UTF-8 did not try to use. Everything doesn't work. I am using file_get_contents to accept. The data comes by subscribing to events.

header('Content-type: text/html; charset=UTF-8');

$data = file_get_contents('php://input');

//$data = mb_convert_encoding($data, 'HTML-ENTITIES', "UTF-8");

//$data = mb_convert_encoding($data, 'UTF-8', "ISO-8859-1");

$data = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $data);

//$data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data, 'UTF-8, ISO-8859-1', true));

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question