如何正确显示SEOStats库的结果';s在google.ch搜索上的getSerps方法


how to correctly display result from SEOStats library's getSerps method on google.ch search?

我使用SEOStats库的getSerps方法来查询google.ch中的特定关键字。当我这样做的时候,结果是有"?"。我相信它们来自瑞士语的特殊字符。

我想在网页上正确显示它们。我已经尝试过utf8_encode和utf8_decode函数,但没有成功。

如果您想在您这边生成此问题,那么只需对SEOstats''Config''DefaultSettings.php文件进行以下更改即可。

const GOOGLE_TLD = 'ch';

并使用关键字"web hosting"调用example/get-google-serps.php文件。你会看到很多"?"在生成的php数组中。

感谢您提前提供帮助。

Bhavesh

我已经通过composer composer require seostats/seostats安装了SEOStats。若您从github下载库,它可能会有所不同。

这是我的'vendor'seostats'seostats'SEOstats'Services'Google.php:

$curledSerp = utf8_decode( self::gCurl($nextSerp, $ref) );

这里是utf8_decode函数(http://php.net/manual/en/function.utf8-decode.php)。此函数将所有utf8字符转换为iso。此函数无法转换的所有字符都将替换为?。尝试删除utf8_decode函数,您的所有utf-8字符都将安全。