如何通过 url 传递特殊字符(例如 %)以在 google 日历中创建新事件
how to pass special character (e.g. %) through url for create new event in google calendar
我正在通过以下 URL 结构在 google 日历中创建一个新事件。
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,代表一个事件的标题。
如果我传递纯字符串,效果很好。但是如果我传递像“%”这样的特殊字符(例如 20% off for Asgardian),那么 google 日历给了我 -
Bad Request
Error 400
如何传递“%”?
(详细信息 也有同样的错误)
在评论中,@terry 给了我如何通过 %
通过 URL 的答案。
我需要将其编码为 %25
.
他还分享了 - Javascript 有一个内置函数用于此 URL 编码。 encodeURIComponent()
如果我们用 encodeURIComponent()
包装我们的字符串,它会给我们 URL 编码的字符串。
谢谢。
我正在通过以下 URL 结构在 google 日历中创建一个新事件。
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,代表一个事件的标题。
如果我传递纯字符串,效果很好。但是如果我传递像“%”这样的特殊字符(例如 20% off for Asgardian),那么 google 日历给了我 -
Bad Request
Error 400
如何传递“%”?
(详细信息 也有同样的错误)
在评论中,@terry 给了我如何通过 %
通过 URL 的答案。
我需要将其编码为 %25
.
他还分享了 - Javascript 有一个内置函数用于此 URL 编码。 encodeURIComponent()
如果我们用 encodeURIComponent()
包装我们的字符串,它会给我们 URL 编码的字符串。
谢谢。