Facebook打开图形og:图像转义空格字符 [英] Facebook open graph og:image escape whitespace characters

查看:146
本文介绍了Facebook打开图形og:图像转义空格字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户提交的照片画廊的页面。我正在使用Facebook API分享照片。它与查询字符串共享页面。当查询字符串存在时,它将设置页面上的所有打开图形属性。除非图像在文件名上有空白字符,否则此功能非常好。

I have a page with user submitted photo galleries. I'm using the facebook API to share the photos. It shares the page with a query string. When the query string is present, it sets all the open graph properties on the page . This works great except when the image has white space characters on the file name.

我已经尝试用'%20'替换空格,因此

I have tried replacing the whitespace characters with '%20' as so

http://example.com/gallery/images/large/this image.jpg

 http://example.com/gallery/images/large/this%20image.jpg

但是,Facebook解析器也不喜欢。

But the facebook parser doesn't like that either.

有没有办法对这些字符进行扫描,或者我将不得不返回并更改它,以便在图像上传时更换?

Is there a way to scape these characters or am I going to have to go back and change it so that it replaces when the images get uploaded?

推荐答案

回答你的问题(原来是),现在(在2017年6月)Facebook解析器与空格字符一起逃逸'%20',希望能帮助有人寻找解决方案。

Answering your question (being it old), Now (in June-2017) Facebook parser works with whitespace characters when escaped with '%20', hope it would help someone looking for solution.

所以,将空格转换为%20,如下所示:

So, convert whitespace to %20 as depicted below:

http://example.com/gallery/images/large/this image.jpg

to

http://example.com/gallery/images/large/this%20image.jpg

服务器端语言具有预定义的功能,例如PHP中的 rawurlencode

Server side language has pre-defined function for that e.g. rawurlencode in PHP.

这篇关于Facebook打开图形og:图像转义空格字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆