尽管将字符集设置为utf8,Utf8 opengraph标题仍会被破坏?

时间:2014-11-02 21:35:03

标签: php utf-8 facebook-opengraph

我正在使用php lib从网站https://github.com/scottmac/opengraph/blob/master/OpenGraph.php

中检索opengraph标签
<?php
header("Content-Type: text/html; charset=utf-8");
$url = 'http://www.youtube.com/watch?v=ogHIUNfu2vY';
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/libs/opengraph/OpenGraph.php';

$graphObj = OpenGraph::fetch($url);

echo '<pre>';
print_r($graphObj);
echo '</pre>';

此标题被错误地检索为

[title] =&gt; HüskerDü - 我永远不会忘记你

应该是

[title] =&gt; HüskerDü - 我永远不会忘记你

如何在utf-8中检索打开的图形标签?

1 个答案:

答案 0 :(得分:-2)

$graph = OpenGraph::fetch($url);
$body = current($graph);
$description = utf8_decode($body['description']);