2013-04-02, 01:22
Another update...
I've got it working using xbmc 12.1 frodo. Json was a little tricky to get sorted as it's rpc vesion 2 so it was giving me errors even it looked ok. The formatting is strict, so I resorted to building it up using arrays in PHP and json encoding it.
I have it working from a php script using curl. I've also worked out using the xbmc api that I can pass in variables over the json command, which I can then pick up in the xbmc app and show on the popup message.
Here's the code triggering the json command
I'm still trying to figure out how I catch the strings in the script and display them on the popup. At the moment all I'm getting is erros but I have this to follow ( http://wiki.xbmc.org/index.php?title=HOW...orld_addon ) so I'll work out a little more tomorrow after work.
I've got it working using xbmc 12.1 frodo. Json was a little tricky to get sorted as it's rpc vesion 2 so it was giving me errors even it looked ok. The formatting is strict, so I resorted to building it up using arrays in PHP and json encoding it.
I have it working from a php script using curl. I've also worked out using the xbmc api that I can pass in variables over the json command, which I can then pick up in the xbmc app and show on the popup message.
Here's the code triggering the json command
PHP Code:
<?php
$blackBoxIP = '10.0.7.12';
$XbmcPort = '8081';
echo "Sending Notification...\n";
$data = array( "jsonrpc" => "2.0",
"id" => "0",
"method" => "Addons.ExecuteAddon",
"params" => array( "addonid"=> "script.doorbell",
"params" => array ( 'image' => 'notificationicon.jpg',
'string1'=> 'Hello World',
'string2'=> 'Showing this message using',
'string3'=> 'Combination of XBMC python modules and',
'string4'=> 'JSON-RPC API interface',
'string5'=> 'Have fun coding'
)
)
);
$data_string = json_encode($data);
$ch = curl_init("http://$blackBoxIP:$XbmcPort/jsonrpc");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Sent succesfully';
}
curl_close($ch);
I'm still trying to figure out how I catch the strings in the script and display them on the popup. At the moment all I'm getting is erros but I have this to follow ( http://wiki.xbmc.org/index.php?title=HOW...orld_addon ) so I'll work out a little more tomorrow after work.