如何使用 fb_graph 在墙贴中包含 html 实体
我花了几个小时在谷歌上搜索这个但一无所获。
我正在使用 Rails 3 应用程序和 fb_graph gem 将消息发布到 Facebook 墙。发布消息一切正常 - 但我需要发布一条带有 e umlat 字符的消息,但这不起作用。
这是测试代码:
message = "efficiënte efficiënte"
me = FbGraph::User.me(self.access_token)
me.feed!(:message => message)
当在 facebook 上运行消息时,第一个 eumlat 具有未知字符符号,并且仅包含如下原始实体:
effici�nte efficiënte
大概我需要以某种特殊方式对字符串进行编码 - 但我可以找到文档中没有任何内容告诉我如何让这个字符正确地出现在用户的提要中。
有人可以帮忙吗?
I've spent several hours googling this and am getting nowhere.
I'm using a Rails 3 app and the fb_graph gem to post a message to a facebook wall. Posting the message all works fine - but I need to post a message with an e umlat charcter in it and this is not working.
This is the test code:
message = "efficiënte efficiënte"
me = FbGraph::User.me(self.access_token)
me.feed!(:message => message)
When run the message on facebook has the unknown character symbol for the first eumlat and just includes the raw entity like this:
effici�nte efficiënte
Presumably I need to encode the string in some special way - but I can find nothing in the documentation that tells me how to get this character to appear in the user's feed properly.
Can anone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧——所以我一发布这篇文章我就发现我做错了什么。
Faceboook API 需要 UTF8(正如您想象的那样),因此第一个编码“efficiënte”应该已经起作用了。
问题是我的 Eclipse 开发环境没有像我假设的那样默认设置为以 UTF8 保存文件。
一旦我更改了 Eclipse ot UFT8 中的文件编码,发送正确的 UTF8 编码文本“efficiënte”就完美地工作了。
希望这对其他人有用。
OK - so no sooner do I post this than I work out what I was doing wrong.
The Faceboook API is expecting UTF8 (as you would imagine) and so the first encoding "efficiënte" should have just worked.
The issue was my Eclipse dev environment is not set to save files in UTF8 by default as I had assumed.
Once I changed the file encoding in Eclipse ot UFT8 sending the properly UTF8 encoded text "efficiënte" worked perfectly.
Hopefully this is of use to someone else.