繁体   English   中英

如何通过 url 传递特殊字符(例如 %)以在谷歌日历中创建新事件

[英]how to pass special character (e.g. %) through url for create new event in google calendar

我正在通过以下 URL 结构在谷歌日历中创建一个新事件。

   https://calendar.google.com/calendar/r/eventedit?
   text=discount for Asgardian&
   dates=20200327T032400Z/20200327T032400Z&
   details=Thor will be there to receive you&
   location=Asgard&
   trp=false&sprop=&sprop=name:

这是一个 URL 变量text ,它表示事件的标题

如果我传递一个普通字符串,它运行良好。 但是如果我传递像 '%' 这样的特殊字符(例如Asgardian 20% 的折扣),那么谷歌日历给了我 -

  Bad Request 
  Error 400

我怎么能通过'%'?

(同样的错误细节也可用)

在评论中,@terry 给了我如何通过 URL 传递%答案。 我需要将其编码为%25

他还分享了这一点 - Javascript 具有用于此 URL 编码的内置函数。 encodeURIComponent()

如果我们用encodeURIComponent()包装我们的字符串,它会给我们 URL 编码的字符串。

谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM