root@sclrdev:/home/sclr/certs/FreshCerts# curl --ftp-ssl --verbose ftp://{abc}/ -u trup:trup --cacert /etc/ssl/certs/ca-certificates.crt
* About to connect() to {abc} port 21 (#0)
* Trying {abc}...
* Connected to {abc} ({abc}) port 21 (#0)
< 220-Cerberus FTP Server - Home Edition
< 220-This is the UNLICENSED Home Edition and may be used for home, personal use only
< 220-Welcome to Cerberus FTP Server
< 220 Created by Cerberus, LLC
> AUTH SSL
< 234 Authentication method accepted
* successfully set certificate verify locations:
* CAfile: …Run Code Online (Sandbox Code Playgroud) 我想在发送之前看看请求中的帖子字段是什么.(用于调试目的).
我正在使用的PHP库(类)已经完成(不是由我),所以我试图理解它.
据我所知,它用于curl_setopt()设置不同的选项,如标题等,然后curl_exec()用于发送请求.
关于如何查看发送哪些帖子字段的想法?
我Expecting value: line 1 column 1 (char 0)在尝试解码JSON 时遇到错误.
我用于API调用的URL在浏览器中工作正常,但在通过curl请求完成时会出现此错误.以下是我用于curl请求的代码.
错误发生在 return simplejson.loads(response_json)
response_json = self.web_fetch(url)
response_json = response_json.decode('utf-8')
return json.loads(response_json)
def web_fetch(self, url):
buffer = StringIO()
curl = pycurl.Curl()
curl.setopt(curl.URL, url)
curl.setopt(curl.TIMEOUT, self.timeout)
curl.setopt(curl.WRITEFUNCTION, buffer.write)
curl.perform()
curl.close()
response = buffer.getvalue().strip()
return response
Run Code Online (Sandbox Code Playgroud)
完全追溯:
追溯:
File "/Users/nab/Desktop/myenv2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/nab/Desktop/pricestore/pricemodels/views.py" in view_category
620. apicall=api.API().search_parts(category_id= str(categoryofpart.api_id), manufacturer = manufacturer, filter = filters, start=(catpage-1)*20, limit=20, sort_by='[["mpn","asc"]]')
File "/Users/nab/Desktop/pricestore/pricemodels/api.py" in search_parts
176. return simplejson.loads(response_json) …Run Code Online (Sandbox Code Playgroud) 我可以通过curl执行以下命令成功创建一个地方:
$ curl -vX POST https://server/api/v1/places.json -d "
auth_token=B8dsbz4HExMskqUa6Qhn& \
place[name]=Fuelstation Central& \
place[city]=Grossbeeren& \
place[address]=Buschweg 1& \
place[latitude]=52.3601& \
place[longitude]=13.3332& \
place[washing]=true& \
place[founded_at_year]=2000& \
place[products][]=diesel& \
place[products][]=benzin \
"
Run Code Online (Sandbox Code Playgroud)
服务器返回HTTP/1.1 201 Created.
现在我想将有效负载存储在JSON文件中,如下所示:
// testplace.json
{
"auth_token" : "B8dsbz4HExMskqUa6Qhn",
"name" : "Fuelstation Central",
"city" : "Grossbeeren",
"address" : "Buschweg 1",
"latitude" : 52.3601,
"longitude" : 13.3332,
"washing" : true,
"founded_at_year" : 2000,
"products" : ["diesel","benzin"]
}
Run Code Online (Sandbox Code Playgroud)
所以我修改了要执行的命令,如下所示:
$ curl -vX POST http://server/api/v1/places.json -d @testplace.json …Run Code Online (Sandbox Code Playgroud) 我正在使用cURL命令行实用程序将HTTP POST发送到Web服务.我想将文件的内容包含在POST的正文实体中.我已尝试使用-d </path/to/filename>类似信息的其他变体--data </path/to/filename> --data-urlencode </path/to/filename>等...文件始终附加.我需要它作为身体实体.
我使用curl得到以下错误:
curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
如何设置此证书验证位置?谢谢.
在Node.js中,除了使用子进程进行CURL调用之外,是否有办法对远程服务器REST API 进行CURL调用并获取返回数据?
我还需要为远程REST调用设置请求标头,并在GET(或POST)中也查询字符串.
我找到了这个:http://blog.nodejitsu.com/jsdom-jquery-in-5-lines-on-nodejs
但它没有显示任何POST查询字符串的方法.
在我的UNIX shell脚本中,当我执行curl命令时,我的curl结果将显示如下,我将其重定向到文件:
{"type":"Show","id":"123","title":"name","description":"Funny","channelTitle":"ifood.tv","lastUpdateTimestamp":"2014-04-20T20:34:59","numOfVideos":"15"}
Run Code Online (Sandbox Code Playgroud)
但是,我希望此输出以可读的JSON格式放入文件中,如下所示:
{"type":"Show",
"id":"123",
"title":"name",
"description":"Funny",
"channelTitle":"ifood.tv",
"lastUpdateTimestamp":"2014-04-20T20:34:59",
"numOfVideos":"15"}
Run Code Online (Sandbox Code Playgroud)
请建议
我在Windows 7 64bit上安装了WAMP.cURL不起作用,但我仍然从WAMP托盘启用它.
我也注释掉extension=php_curl.dll在php.ini为PHP和Apache文件夹两者.
Windows给我一个错误信息,
PHP启动:无法加载动态库'c:/wamp/bin/php/php5.4.3/ext/php_curl.dll' - 应用程序无法启动,因为它的并排配置不正确.请参阅应用程序事件日志或使用命令-lin sxstrace.exe工具获取更多详细信息."
我该如何解决这个问题?