curl:没有指定URL

5 php api curl

我试图学习Laravel 4:RESTful API的开始

我已经走了一半,然后我面临一个小问题.

我被困在了 It's time to test this with another curl request. This one will send a POST request, which will correspond to the store() method created above.

我跑了这个命令

$ curl -i --user firstuser:first_password -d 'url=http://google.com&description=A Search Engine' localhost/laravel-1/public/index.php/api/v1/url
Run Code Online (Sandbox Code Playgroud)

我应该看到这样的

HTTP/1.1 201 Created
Date: Tue, 21 May 2013 19:10:52 GMT
Content-Type: application/json

{"error":false,"message":"URL created"}
Run Code Online (Sandbox Code Playgroud)

但我看到了这个:(

在此输入图像描述

网址不再有效吗?或者我做错了什么?

Bar*_*mar 4

我认为在 Windows 上你需要使用双引号来引用参数,而不是单引号。结果,该命令在 后结束http://google.com,此后的所有内容都被视为以 开头的新命令description

$ curl -i --user firstuser:first_password -d "url=http://google.com&description=A Search Engine" localhost/laravel-1/public/index.php/api/v1/url
Run Code Online (Sandbox Code Playgroud)

您复制的教程中的示例是在 Unix 上运行的,而不是在 Windows 上运行的。它使用双引号和单引号来引用参数。