我从博客中获取所有帖子数据,但是当我输出数据时,有些特殊字符没有显示json_decode。我还尝试了 json_encode($ resp,JSON_UNESCAPED_UNICODE)。但它仍然无效,我将如何转换它们?请参阅下面的输出
<?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();
}
?>
输出
[title] => Notes of Class 9th: Ch 3 परमाणॠà¤à¤µà¤‚ अणॠविजà¥à¤žà¤¾à¤¨