(2012-04-03 20:47)DecK Wrote:1. Adapted from http://www.voidspace.org.uk/python/artic...ib2.shtml:
- How, in python, do a inititiate a call to a remote instance of XBMC (identifed by a IP4 address) to return:
- the OS of the remote instance.
- the full path to the userdata folder on the remote machine
Again, not dismissing the pull approach, just trying to see if I can get the push to work first.
PHP Code:
import urllib
import urllib2
username = 'user'
password = 'pass'
host = '192.168.1.1'
port = '9090'
url = 'http://%s:%s@%s:%s/jsonrpc' %(username, pass, host, port)
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
values = {"jsonrpc": "2.0", "method": "AudioPlayer.PlayPause", "id": "1"}
headers = { 'User-Agent' : user_agent }
data = urllib.urlencode(values)
req = urllib2.Request(url, data, headers)
response = urllib2.urlopen(req)
the_page = response.read()
I'm doing this on the fly and about to leave, but that should get you started, you can set any necessary headers in the headers dict change the JSON string in values as needed. Reference http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4 to see what you need to change "values" to to get the desired result


Search
Help