【问题标题】:Tweets from API have strange characters (Abraham library)来自 API 的推文有奇怪的字符(亚伯拉罕图书馆)
【发布时间】:2013-08-09 12:51:07
【问题描述】:

我正在使用这个库 (Abraham twitteroauth) 从时间轴中提取推文...

$connection = getConnectionWithAccessToken(TOKEN, TOKEN_SECRET);
$tweets = $connection->get('statuses/user_timeline', array('screen_name' => 'francis_narcise'));

一切正常,但输出中有很多有趣的字符,例如““”代替双引号。

有人知道为什么会这样吗?

【问题讨论】:

    标签: php api twitter oauth


    【解决方案1】:

    您从库中获得的结果在UTF-8 中。正确设置输出的字符集或使用正确的转义功能。

    例如输出为HTML时,可以将页面的字符集设置为UTF-8:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    

    或者,您可以使用htmlentities 转义字符:

    echo htmlentities($tweet);
    

    【讨论】:

    • 天哪,我怎么会忽略这么简单的事情。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 1970-01-01
    • 2016-07-07
    相关资源
    最近更新 更多