2013-04-29 90 views
-1

我使用php-aria2来下载远程文件。但是对127.0.0.1:8100/jsonrpc的所有请求都返回null。 aria2c从命令行工作正常。php-aria2 JSONRPC来自服务器的空回复

当我运行这个命令行

curl http://127.0.0.1:6800/jsonrpc -H "Content-Type: application/json" -H "Accept: application/json" --data '{{"jsonrpc": "2.0","id":1, "method": "aria2.getGlobalStat", "params":[]}' -G 

我:

卷曲:(52)空从服务器应答

有人知道如何解决这一问题?

回答

1

简单的解决方法是去除冗余 “{” 和使用POST不是GET的:

curl http://127.0.0.1:6800/jsonrpc -H "Content-Type: application/json" -H "Accept: application/json" --data '{"jsonrpc": "2.0","id":1, "method": "aria2.getGlobalStat", "params":[]}' 

aria2支持JSON-RPC在GET请求,但它需要被正确编码。见http://aria2.sourceforge.net/manual/en/html/aria2c.html#json-rpc-using-http-get

0
curl http://127.0.0.1:6800/jsonrpc --data "{\"jsonrpc\": \"2.0\",\"id\":1, \"method\": \"aria2.getGlobalStat\", \"params\":[]}" 

curl http://127.0.0.1:6800/jsonrpc --data "{"""jsonrpc""": """2.0""","""id""":1, """method""": """aria2.getGlobalStat""", """params""":[]}" 
0
curl -H 'Content-Type:application/json' -d '{"jsonrpc":"2.0","id":"qwer","method":"aria2.getGlobalStat", "params": []}' http://localhost:6800/jsonrpc 

如果我们--rpc秘密= TOKEN需要这个

curl -H 'Content-Type:application/json' -d '{"jsonrpc":"2.0","id":"qwer","method":"aria2.getGlobalStat", "params": ["token:TOKEN"]}' http://localhost:6800/jsonrpc