[JSON API] Help with callbacks
[JSON API] Help with callbacks
I'm trying to use the JSON API, however I'm a bit puzzled by the use of the callbacks. If I'm on a remote machine, sending these JSON requests, how can I specify a callback?
Re: JSON API callbacks
I asked damoxc about your question and hes not entirely sure what you are trying to do and would need some more clarification however he supplied these links:
damoxc wrote: http://deluge-torrent.org/docs/master/m ... /auth.html
http://deluge-torrent.org/docs/master/m ... n_api.html
here's the update_ui function:
http://git.deluge-torrent.org/deluge/tr ... UI.js#n120
Re: JSON API callbacks
Essentially, at this point, I'm just trying to get anything out of Deluge, using curl. Once I do that I'll move onto something else. I haven't used JSON-RPC before so I'm unsure if I'm doing something wrong. Here's what I'm trying at the moment.
The binary is the output of the command, which I find strange. If I change the URL to /json/rpc I get a HTML 404 page.
Code: Select all
$ curl -X POST --data '{"id": 1, "method": "login", "params": ["password"]}' http://localhost:8112/json
�V�LQ�R0�QP*J-.�)r�Jsr��Ԣ��" �Z)7��81=�V
����/�S�M-��OQ*K�O���v�~SL
Re: JSON API callbacks
The first problem is that you need to use the method auth.login and secondly the response is gzipped so by adding the compressed option, it will uncompress the data. Finally in order to connect you need to store the session id in a cookie. Here is an example using curl:
Hope this helps.
Code: Select all
curl -c cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "auth.login", "params": ["deluge"], "id": 1}' http://localhost:8112/json
Code: Select all
curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "web.connected", "params": [], "id": 1}' http://localhost:8112/json
Code: Select all
curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "web.get_torrent_files", "params": ["<torrentid>"], "id": 1}' http://localhost:8112/json