XBMC api get request in php with curl -
i'm trying request xbmc api in php, cant work. have valid url, thats working when simulate request rest client.
http://localhost:8085/jsonrpc?request={"jsonrpc": "2.0", "id": 1, "method": "input.executeaction", "params": {"action":"left"}}
i parse error xbmc when simulate post:
{ "error": { "code": -32700, "message": "parse error." }, "id": null, "jsonrpc": "2.0" }
this code have:
<?php $jsonstring = "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"input.executeaction\", \"params\": {\"action\":\"left\"}}"; $url = "http://localhost:8085/jsonrpc?request=".$jsonstring; get($url); function get($url){ $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout , 7); $result = curl_exec($ch); print $result; curl_close($ch); }
but wont job, when simulate post request parse error returned. thoughts i'm doing post request, i? if no, problem then?
i ran same problem. need encode url using xbmc (kodi nowadays). in case:
$jsonstring
should replaced by
urlencode($jsonstring)
Comments
Post a Comment