如何在 JavaScript 中使用 Curl

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11839170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 07:19:01  来源:igfitidea点击:

How to use Curl in javascript

javascriptgoogle-chrome-extension

提问by Chandeep

I am writing a chrome extension and I want to use Curl to get me the download links of the gmail attachments. How should i do it? I am new to curl and i don't know how would i able to use the curl library in javascript ?

我正在编写一个 chrome 扩展程序,我想使用 Curl 来获取 gmail 附件的下载链接。我该怎么做?我是 curl 的新手,我不知道如何在 javascript 中使用 curl 库?

采纳答案by Prasanth

You can't use cURL directly in Javascript. You can do AJAX though. So one solution would be to setup a php script somewhere that you can use for getting links from gmail.

您不能在 Javascript 中直接使用 cURL。不过你可以做 AJAX。因此,一种解决方案是在某个地方设置一个 php 脚本,您可以使用该脚本从 gmail 获取链接。

EDIT: There is an implementationof cURL in javascript here. Check it out.

编辑:在 javascript here 中有一个cURL的实现。一探究竟。

回答by chris_bart0n

Just as a reference same origin policyin javascript. While there appears to workarounds this, security is always going to be a concern.

就像在 javascript 中引用同源策略一样。虽然似乎有解决方法,但安全性始终是一个问题。