通过curl获取GET和POST请求

时间:2016-03-07 04:55:41

标签: post curl get

是否可以通过linux终端使用curl发送GET和POST请求?

基本上,我试图了解这些人在本教程中做了些什么,但我不明白如何在他们的教程示例中添加额外的GET参数。

例如,在他们的教程(http://valeriobasile.github.io/candcapi/)中,他们使用了以下示例:

curl -d 'Every man loves a woman' 'http://gingerbeard.alwaysdata.net/candcapi/proxy.php/raw/pipeline?semantics=fol'

它有效,但我想要一个图形表示。他们在他们的例子Here中也提到了这一点。

"An entry point to generate a PNG image...

$CANDCAPT/drg

"The URL accepts the same GET parameter as pipeline."

所以我尝试发送此信息,但它没有获得PNG文件:

curl -d 'Every man loves a woman&pipeline' 'http://gingerbeard.alwaysdata.net/candcapi/proxy.php/raw/pipeline?semantics=drs&roles=verbnet'

这实际上打破了他们的系统。

curl -d 'Every man loves a woman' 'http://gingerbeard.alwaysdata.net/candcapi/proxy.php/raw/pipeline?semantics=drs&roles=verbnet%20%@d%2dbox'

所以我的问题是,当我们说url接受相同的GET参数时,我不太确定开发人员的意思,我将如何添加?如果您有任何想法,请告诉我,谢谢。

编辑1 -

我尝试添加drg而不是管道,但它返回一条消息,说“" not found"

curl -d 'Every man loves a woman' 'http://gingerbeard.alwaysdata.net/candcapi/proxy.php/drg?semantics=fol'

1 个答案:

答案 0 :(得分:1)

我阅读了GitHub文档,并在底部描述了如何获取图形输出:

  

C& C / Boxer API提供了一个入口点,用于生成给定文本的DRG的PNG图像:

     

$ CANDCAPI / DRG

     

URL接受与管道相同的GET参数并返回原始PNG文件。

基于此,您的GET网址应如下所示:

http://gingerbeard.alwaysdata.net/candcapi/proxy.php/drg?semantics=fol

使用“相同”的GET参数意味着在之后传递给pipeline 的任何内容也可以传递给drg网络服务。

修改了anwser:

以下是来自同一示例的正确命令:

curl -d 'Every man loves a woman' 'http://gingerbeard.alwaysdata.net/candcapi/drg?semantics=fol'

对于像我这样的初学者,这里是保存png文件:

curl -d 'Every man loves a woman' 'http://gingerbeard.alwaysdata.net/candcapi/drg?semantics=fol' >> image.png