如何使用书签通过 API 的 HTTP POST 将文本粘贴到 Pastebin 站点?
我想通过站点的 API 将一些文本粘贴到 Pastebin 站点。
正如我所发现的(我的编程知识有限),我需要两件事:首先处理选定的文本,然后通过 HTTP POST 将其发布到 Pastebin 站点。
我尝试这样做...
javascript:'<body%20onload="document.forms[0].submit()"><form%20method="post"%20action="http://sprunge.us"><input%20type="hidden"%20name="sprunge"%20value="+ document.getSelection() +"></form>'
....(你猜对了!)每次都会返回到我选择的文本为“+ document.getSelection() +”的页面。
有什么帮助吗?
I want to paste some text to a pastebin site through the site's API.
As I have figured out (I have limited knowledge of programming) I need two things: First to process the selected text and then to post it via HTTP POST to the pastebin site.
I tried to do this...
javascript:'<body%20onload="document.forms[0].submit()"><form%20method="post"%20action="http://sprunge.us"><input%20type="hidden"%20name="sprunge"%20value="+ document.getSelection() +"></form>'
....which (you guessed it!) returns to me EVERY TIME a page in which the selected text being "+ document.getSelection() +".
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须以编程方式制作一个表单,添加所需的字段,然后发布——所有这些都用 JavaScript 进行。
这是一个示例 - 您至少需要更改 URL 和字段名称:
上面的压缩内容没有注释和换行符:
我不熟悉 sprunge.us,但如果您有示例中的 URL 和字段名,您可以通过搜索替换来使其工作:
您还应该删除我的示例中包含的第二个字段(some_field_1、somefield_value_1)。
You have to make a form programmatically, add the fields required and then post -- all in JavaScript.
Here is an example -- you will at least have to change the URL and the fieldname:
The above compacted without comments and linebreaks:
I'm not familiar with sprunge.us, but if you've got the URL and fieldname right in your example, you could get this to work by search-replace:
You should also remove the second field (some_field_1, somefield_value_1) included in my example.