[GH-ISSUE #21] 请问下自己搭建的网址推送不了。是什么原因呢? #16

Closed
opened 2026-03-03 11:55:22 +03:00 by kerem · 4 comments
Owner

Originally created by @asdfvv on GitHub (Oct 17, 2020).
Original GitHub issue: https://github.com/Finb/bark-server/issues/21

请问下大佬,自己搭建的文字可以推,网址就不能推。
带“/”符号的推送什么自己换行,如home/test,会变成一行home,一行test。只能复制到test
听说要转换字符吗?请问下怎么设置?
谢谢

Originally created by @asdfvv on GitHub (Oct 17, 2020). Original GitHub issue: https://github.com/Finb/bark-server/issues/21 请问下大佬,自己搭建的文字可以推,网址就不能推。 带“/”符号的推送什么自己换行,如home/test,会变成一行home,一行test。只能复制到test 听说要转换字符吗?请问下怎么设置? 谢谢
kerem closed this issue 2026-03-03 11:55:22 +03:00
Author
Owner

@Finb commented on GitHub (Oct 17, 2020):

需要给参数URL编码,否则如果参数中包含 / 会破坏URL结构

例如

//给参数URL编码一下就行(各语言有不同的URL编码方法,方法名可能不一样)。
var url:String = "https://api.day.app/yourkey/" + "home/test".encodeURIComponent();   

//最后URL长这样
printf(url);  //https://api.day.app/yourkey/home%2ftest/

// 如果不编码则会产生歧义
// https://api.day.app/yourkey/home/test/
// 服务器会以为你请求的是 https://api.day.app/yourkey/{title}/{body}/  
// 自然就会分两行显示了,一行粗体title ,一行常规字体body

<!-- gh-comment-id:710999637 --> @Finb commented on GitHub (Oct 17, 2020): 需要给参数URL编码,否则如果参数中包含 / 会破坏URL结构 例如 ```swift //给参数URL编码一下就行(各语言有不同的URL编码方法,方法名可能不一样)。 var url:String = "https://api.day.app/yourkey/" + "home/test".encodeURIComponent(); //最后URL长这样 printf(url); //https://api.day.app/yourkey/home%2ftest/ // 如果不编码则会产生歧义 // https://api.day.app/yourkey/home/test/ // 服务器会以为你请求的是 https://api.day.app/yourkey/{title}/{body}/ // 自然就会分两行显示了,一行粗体title ,一行常规字体body ```
Author
Owner

@asdfvv commented on GitHub (Oct 18, 2020):

谢谢大佬解答,不过我是小白一个。
是不是要在哪加个参数?我用docker搭建的

<!-- gh-comment-id:711170407 --> @asdfvv commented on GitHub (Oct 18, 2020): 谢谢大佬解答,不过我是小白一个。 是不是要在哪加个参数?我用docker搭建的
Author
Owner

@Finb commented on GitHub (Oct 19, 2020):

服务端是正常的,是因为你拼的请求URL本身有问题,你可以去查一些 URL编码 相关的文章看一看

或者
你不用把参数拼在URL路径里,用下面的格式去发推送
https://api.day.app/yourkey/?body={你要推送的内容}

<!-- gh-comment-id:711543209 --> @Finb commented on GitHub (Oct 19, 2020): 服务端是正常的,是因为你拼的请求URL本身有问题,你可以去查一些 URL编码 相关的文章看一看 或者 你不用把参数拼在URL路径里,用下面的格式去发推送 https://api.day.app/yourkey/?body={你要推送的内容}
Author
Owner

@asdfvv commented on GitHub (Oct 19, 2020):

好的,谢谢大佬。我在去试试

<!-- gh-comment-id:711755601 --> @asdfvv commented on GitHub (Oct 19, 2020): 好的,谢谢大佬。我在去试试
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bark-server#16
No description provided.