简体   繁体   中英

Facebook API encoding issue

I'm implementing facebook login on my site and the auth process works fine, but there is another problem. When I try to get the name of the user from the auth response, I'm getting this:

Array ( [name] => Ðиколай ДÑнков [image] => ...

This name is supposed to be in Cyrillic characters and I need to:

  1. Display it to the user in cyrilic
  2. Store it safely in database and be able to convert it back to cyrillic later

I tried using json_decode() and iconv() but no success. Maybe I can't get the parameters right. Please help!

Use header to modify the HTTP header:

header('Content-Type: text/html; charset=utf-8');

Place it at the top of your php file or at a common file which you include everywhere, such as config file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM