0

I am getting all the post data from my blogger, but when I output data there are some special characters are not being displayed with json_decode. I also tried json_encode($resp, JSON_UNESCAPED_UNICODE). But it still didn't work, how will I convert them ? Please see the output below

<?php
$blogId = '123';
$appId = 'abc';
$url = "https://www.googleapis.com/blogger/v3/blogs/{$blogId}/posts?key=
{$appId}";
try{
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_HTTPGET, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $resp = curl_exec($ch);
 curl_close($ch);
 $posts = json_decode($resp, true);

 $allposts = array();
 echo "<pre>";
 foreach ($posts['items'] as $post) {
   array_push($allposts, array(
    "title" => $post['title'],
    "published" => $post['published'],
    "updated" => $post['updated'],
    "labels" => $post['labels'][0]
    ));
  }
 print_r($allposts);
 echo "</pre>";
}catch(Exception $ex){
 echo $ex->getMessage();
}
?>

OUTPUT

[title] => Notes of Class 9th: Ch 3 परमाणॠà¤à¤µà¤‚ अणॠविजà¥à¤žà¤¾à¤¨ 
topper1309
  • 151
  • 3
  • 16
  • So what does the json look like? – KIKO Software Jan 25 '18 at 22:48
  • @KIKOSoftware The title has special characters, but actually it is "परमाणु एवं अणु विज्ञान" but instead it is being displayed as output above – topper1309 Jan 25 '18 at 22:50
  • Which OS do you use? – LMC Jan 25 '18 at 22:59
  • Your data is being transmitted fine, but the thing that's displaying the data is displaying multi-byte UTF8 data as single-byte ISO8859 or similar. Don't use `JSON_UNESCAPED_UNICODE` and see: https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Sammitch Jan 25 '18 at 23:57

0 Answers0