【问题标题】:Blogger - How to Percent Encode an URL / Escape It to Use as Query Param?Blogger - 如何对 URL 进行百分比编码/转义以用作查询参数?
【发布时间】:2018-01-22 19:02:59
【问题描述】:

在 blogspot 模板引擎中,如何转义帖子 URL 以将其用作查询参数,以便可以在 facebook/twitter/任何按钮和 iframe 中使用它?

问题:我有一个带有 src 的 iframe,它需要一个 URL。

<iframe src="https://www.facebook.com/plugins/like.php?href=MY_URL_GOES_HERE">

所以说我的帖子网址是http://example.blogspot.com/1999/01/first.html。我需要将:/. 转换为百分比编码字符,以及?&amp;% 等。否则我会得到这个:

<iframe src="https://www.facebook.com/plugins/like.php?href=http://example.blogspot.com/1999/01/first.html">

而且看起来它总有一天会被打破。如何在博客中转义 URL?

【问题讨论】:

    标签: facebook twitter blogger blogspot


    【解决方案1】:

    做到这一点的方法非常简单,只需要浪费几个小时在互联网的每个角落搜索一些关于 blogspot 模板引擎的类似文档,并阅读一堆 StackOverflow 的答案,这些答案只是用“改用 shareurl。”

    无论如何。 blogspot 模板中的每个字符串都有一个.escaped 字段,该字段是转义的字符串。这就对了。你只是 anyurl.escaped 并且它有效。可以是data:post.url.escapeddata:post.url.canonical.escaped 或其他。

    <iframe
      expr:src="&quot;https://www.facebook.com/plugins/like.php?href=&quot;
        + data:post.url.canonical.escaped + &quot;width=173&amp;layout=button_count&amp;action=like&amp;size=small&amp;show_faces=false&amp;share=true&amp;height=46&amp;appId=YOUR_APP_ID_HERE&quot;" width="173"
    height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    

    其他难以捉摸的字符串属性可以在这个极其可疑的博客中找到:http://template-data.blogspot.com.br/2016/04/title_58.html

    您认为 google 会在某个容易找到的地方提供此信息,但他们得到的只是博客 HTTP API 文档?什么?

    【讨论】:

      猜你喜欢
      • 2018-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多