OSCam/de/XML API: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
(→Intro: Link zum Forums-Thread eingefügt) |
||
(7 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
[[Kategorie:OSCam]] | [[Kategorie:OSCam]] | ||
{{OSCamHomeLinks}} | {{OSCamHomeLinks}} | ||
<span style="background-color:Blue;color:White;padding:0 5px;">ÄNDERUNG - CHANGE - MODIFICATIONS - MODIFICA svn4835:03/19/2011</span> | |||
== XML API == | == XML API == | ||
Zeile 10: | Zeile 12: | ||
[[Datei:MessageS.png|text-bottom]] '''Info:''' Die XML API ist selbst noch in der Entwicklung. Nachfolgende Informationen wurden mit ''OSCAM 1.00-unstable_svn build #4641'' gesammelt. | [[Datei:MessageS.png|text-bottom]] '''Info:''' Die XML API ist selbst noch in der Entwicklung. Nachfolgende Informationen wurden mit ''OSCAM 1.00-unstable_svn build #4641'' gesammelt. Hier ist der entsprechende Thread im Forum: http://www.streamboard.tv/wbb2/thread.php?threadid=30478 . | ||
=== Übersicht === | === Übersicht === | ||
Zeile 24: | Zeile 26: | ||
Reader Entitlement (momentan nur cccam reader - Karten): | Reader Entitlement (momentan nur cccam reader - Karten): | ||
/oscamapi.html?part=entitlement&label=<readername> | /oscamapi.html?part=entitlement&label=<readername> | ||
User Statistik (seit [[Streamboard:oscam/changeset/4835/trunk|r4835]]) | |||
/oscamapi.html?part=userstats | |||
or | |||
/oscamapi.html?part=userstats&label=<username> | |||
Bei falschem Aufruf sollte überall eine auswertbare XML Fehlermeldung kommen: | Bei falschem Aufruf sollte überall eine auswertbare XML Fehlermeldung kommen: | ||
<syntaxhighlight lang="xml"> | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<oscam version="1.00-unstable_svn build #4437" starttime="2011-01-12T23:44:35+0100" uptime="124500" > | |||
<error>part not found</error> | |||
</oscam> | |||
</syntaxhighlight> | |||
[[Datei:MessageS.png|text-bottom]] '''Info:''' Datumsangaben sind in ISO - Zeitangaben in integer Sekunden | [[Datei:MessageS.png|text-bottom]] '''Info:''' Datumsangaben sind in ISO - Zeitangaben in integer Sekunden | ||
Zeile 35: | Zeile 44: | ||
=== Beispielausgaben === | === Beispielausgaben === | ||
Status ohne Log '''''/oscamapi.html?part=status''''': | Status ohne Log '''''/oscamapi.html?part=status''''': | ||
<syntaxhighlight lang="xml"> | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<oscam version="1.00-unstable_svn build #4641" starttime="2011-01-28T16:00:17+0100" uptime="643" > | |||
<status> | |||
<client type="s" name="root" protocol="server" protocolext="" au="0"> | |||
<request caid="0000" srvid="0000" ecmtime="0" answered=""></request> | |||
<times login="2011-01-28T16:00:17+0100" online="643" idle="0"></times> | |||
<connection ip="127.0.0.1" port="0">OK</connection> | |||
</client> | |||
<client type="h" name="root" protocol="monitor" protocolext="" au="0"> | |||
<request caid="0000" srvid="0000" ecmtime="0" answered=""></request> | |||
<times login="2011-01-28T16:00:17+0100" online="643" idle="0"></times> | |||
<connection ip="127.0.0.1" port="0">OK</connection> | |||
</client> | |||
<client type="r" name="my_reader_1" protocol="mouse" protocolext="" au="0"> | |||
<request caid="0000" srvid="0000" ecmtime="0" answered=""></request> | |||
<times login="2011-01-28T16:00:17+0100" online="643" idle="630"></times> | |||
<connection ip="127.0.0.1" port="0">CARDOK</connection> | |||
</client> | |||
<client type="r" name="my_reader_2" protocol="mouse" protocolext="" au="0"> | |||
<request caid="0000" srvid="0000" ecmtime="0" answered=""></request> | |||
<times login="2011-01-28T16:00:17+0100" online="643" idle="629"></times> | |||
<connection ip="127.0.0.1" port="0">CARDOK</connection> | |||
</client> | |||
<client type="r" name="my_reader_3" protocol="mouse" protocolext="" au="0"> | |||
<request caid="0000" srvid="0000" ecmtime="0" answered=""></request> | |||
<times login="2011-01-28T16:00:17+0100" online="643" idle="630"></times> | |||
<connection ip="127.0.0.1" port="0">CARDOK</connection> | |||
</client> | |||
<client type="c" name="cccam_2" protocol="newcamd (CCcam)" protocolext="" au="0"> | |||
<request caid="FFFE" srvid="FFFE" ecmtime="0" answered=""></request> | |||
<times login="2011-01-28T16:00:33+0100" online="627" idle="58"></times> | |||
<connection ip="127.0.0.1" port="43111">OK</connection> | |||
</client> | |||
<client type="c" name="cccam_3" protocol="newcamd (CCcam)" protocolext="" au="0"> | |||
<request caid="1702" srvid="00CA" ecmtime="0" answered="invalid"></request> | |||
<times login="2011-01-28T16:00:33+0100" online="627" idle="23"></times> | |||
<connection ip="127.0.0.1" port="33222">OK</connection> | |||
</client> | |||
<client type="c" name="cccam_1" protocol="newcamd (CCcam)" protocolext="" au="0"> | |||
<request caid="1702" srvid="00CA" ecmtime="1" answered="invalid"></request> | |||
<times login="2011-01-28T16:00:56+0100" online="604" idle="23"></times> | |||
<connection ip="127.0.0.1" port="40333">OK</connection> | |||
</client> | |||
</status> | |||
<log><![CDATA[]]></log> | |||
</oscam> | |||
</syntaxhighlight> | |||
Readerstatus mit EMM und LB Stats '''''/oscamapi.html?part=readerstats&label=<readername>''''' | Readerstatus mit EMM und LB Stats '''''/oscamapi.html?part=readerstats&label=<readername>''''' | ||
<syntaxhighlight lang="xml"> | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<oscam version="1.00-unstable_svn build #4641" starttime="2011-01-28T16:00:17+0100" uptime="1718" > | |||
<reader label="my_reader_1"> | |||
<emmstats totalwritten="4" totalskipped="0" totalblocked="0" totalerror="0"> | |||
<emm type="unknown" result="error">0</emm> | |||
<emm type="unique" result="error">0</emm> | |||
<emm type="shared" result="error">0</emm> | |||
<emm type="global" result="error">0</emm> | |||
<emm type="unknown" result="written">0</emm> | |||
<emm type="unique" result="written">0</emm> | |||
<emm type="shared" result="written">0</emm> | |||
<emm type="global" result="written">4</emm> | |||
<emm type="unknown" result="skipped">0</emm> | |||
<emm type="unique" result="skipped">0</emm> | |||
<emm type="shared" result="skipped">0</emm> | |||
<emm type="global" result="skipped">0</emm> | |||
<emm type="unknown" result="blocked">0</emm> | |||
<emm type="unique" result="blocked">0</emm> | |||
<emm type="shared" result="blocked">0</emm> | |||
<emm type="global" result="blocked">0</emm> | |||
</emmstats> | |||
<ecmstats count="1" totalecm="68" lastaccess="2011-01-28T16:28:52+0100"> | |||
<ecm caid="1702" provid="000000" srvid="00DF" channelname="Bundesliga" avgtime="541" lasttime="543" rc="0" rcs="found" lastrequest="2011-01-28T16:28:52+0100">68</ecm> | |||
</ecmstats> | |||
</reader> | |||
</oscam> | |||
</syntaxhighlight> | |||
User statistics '''''/oscamapi.html?part=userstats&label=<username>''''' | |||
<syntaxhighlight lang="xml"> | |||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
<oscam version="1.00-unstable_svn build # | <oscam version="1.00-unstable_svn build #4840" revision="4840" starttime="2011-03-19T17:52:41+0000" uptime="1872" > | ||
< | <users> | ||
< | <user name="tm800"> | ||
< | <stats> | ||
<cwok>238</cwok> | |||
<cwnok>10</cwnok> | |||
<cwignore>6</cwignore> | |||
<cwtimeout>0</cwtimeout> | |||
<cwcache>0</cwcache> | |||
<cwtun>0</cwtun> | |||
<cwlastresptime>109</cwlastresptime> | |||
<emmok>0</emmok> | |||
<emmnok>0</emmnok> | |||
<cwrate>7.49</cwrate> | |||
< | </stats> | ||
</user> | |||
</users> | |||
<totals> | |||
<cwok>597</cwok> | |||
</ | <cwnok>10</cwnok> | ||
< | <cwignore>6</cwignore> | ||
<cwtimeout>0</cwtimeout> | |||
</ | <cwcache>0</cwcache> | ||
</ | <cwtun>0</cwtun> | ||
</totals> | |||
</oscam> | </oscam> | ||
</syntaxhighlight> | |||
=== XML-Parsing: PHP-Beispiel === | === XML-Parsing: PHP-Beispiel === | ||
<syntaxhighlight lang="php"> | |||
<?php | |||
# OSCam XML API example in PHP | |||
# USER SETUP *********************************************** | |||
$_CONSTANTS = array( | |||
'OSCAM_URL' => 'http://127.0.0.1:4711/oscamapi.html' | |||
,'LOCAL_ACCESS_ONLY' => true # true = call OSCam XML API by "wget"; false = call OSCam XML API by URL - default = true | |||
,'NL' => "\n" # Newline | |||
); | |||
# END USER SETUP ******************************************* | |||
# define constants ***************************************** | |||
foreach($_CONSTANTS as $key => $val) { | |||
if(is_array($_CONSTANTS[$key])) $$key = $val; | |||
else define($key, $val); | |||
} | |||
# save memory... | |||
unset($_CONSTANTS); | |||
# private vars ********************************************* | |||
define('PART_NAME', 'part'); | |||
# OSCam class ********************************************** | |||
class OSCam { | |||
public function getXMLfile($part) { | |||
$r = null; | |||
if(LOCAL_ACCESS_ONLY) { | |||
$r = trim(shell_exec('wget -O - "'.OSCAM_URL.'?'.PART_NAME.'='.$part.'"')); | |||
} else { | |||
$r = file_get_contents(OSCAM_URL.'?'.PART_NAME.'='.$part); | |||
} | |||
return $r; | |||
} | |||
public function getStatusNumOfType(&$xml, $nType) { | |||
$r = 0; | |||
$x = new SimpleXMLElement($xml); | |||
foreach($x->status->client as $c) { | |||
if(!empty($c['type']) && $c['type'] == $nType) $r++; | |||
} | |||
return $r; | |||
} | |||
} | |||
# OUTPUT-EXAMPLES ****************************************** | |||
$oc = new OSCam; | |||
# status | |||
$xml = $oc->getXMLfile('status'); | |||
echo NL.'<h1>XML status content:</h1>'.NL; | |||
echo '<pre>'.htmlspecialchars($xml).'</pre>'; | |||
echo NL.'<h1>Number of readers:</h1>'.NL; | |||
$t = $oc->getStatusNumOfType($xml, 'r'); | |||
echo '<pre>'.$t.'</pre>'; | |||
echo NL.'<h1>Number of active clients:</h1>'.NL; | |||
$t = $oc->getStatusNumOfType($xml, 'c'); | |||
echo '<pre>'.$t.'</pre>'; | |||
?> | |||
</syntaxhighlight> | |||
{{OSCamTranslatedLinks}} | {{OSCamTranslatedLinks}} |
Aktuelle Version vom 31. Dezember 2013, 18:48 Uhr
OSCam Übersicht OSCam Home OSCam Accueil OSCam Home
ÄNDERUNG - CHANGE - MODIFICATIONS - MODIFICA svn4835:03/19/2011
XML API
Intro
OSCam beinhaltet auch eine API (Application Programming Interface), die z.B. für Imagebauer, Plugin-Entwickler, etc., von großem Nutzen sein kann. Der Zugriff auf die API erfolgt per http oder https.
Kurzum: Mit der XML API können OSCam-Informationen, wie z.B. version, starttime, uptime, ..., sowie auch OSCam-Status, ausgewertet werden.
Info: Die XML API ist selbst noch in der Entwicklung. Nachfolgende Informationen wurden mit OSCAM 1.00-unstable_svn build #4641 gesammelt. Hier ist der entsprechende Thread im Forum: http://www.streamboard.tv/wbb2/thread.php?threadid=30478 .
Übersicht
Status ohne Log:
/oscamapi.html?part=status
Status mit Log:
/oscamapi.html?part=status&appendlog=1
Readerstatus mit EMM und LB Stats:
/oscamapi.html?part=readerstats&label=<readername>
Reader Entitlement (momentan nur cccam reader - Karten):
/oscamapi.html?part=entitlement&label=<readername>
User Statistik (seit r4835)
/oscamapi.html?part=userstats
or
/oscamapi.html?part=userstats&label=<username>
Bei falschem Aufruf sollte überall eine auswertbare XML Fehlermeldung kommen: <syntaxhighlight lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <oscam version="1.00-unstable_svn build #4437" starttime="2011-01-12T23:44:35+0100" uptime="124500" >
<error>part not found</error>
</oscam> </syntaxhighlight>
Info: Datumsangaben sind in ISO - Zeitangaben in integer Sekunden
Beispielausgaben
Status ohne Log /oscamapi.html?part=status: <syntaxhighlight lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <oscam version="1.00-unstable_svn build #4641" starttime="2011-01-28T16:00:17+0100" uptime="643" >
<status> <client type="s" name="root" protocol="server" protocolext="" au="0"> <request caid="0000" srvid="0000" ecmtime="0" answered=""></request> <times login="2011-01-28T16:00:17+0100" online="643" idle="0"></times> <connection ip="127.0.0.1" port="0">OK</connection> </client> <client type="h" name="root" protocol="monitor" protocolext="" au="0"> <request caid="0000" srvid="0000" ecmtime="0" answered=""></request> <times login="2011-01-28T16:00:17+0100" online="643" idle="0"></times> <connection ip="127.0.0.1" port="0">OK</connection> </client> <client type="r" name="my_reader_1" protocol="mouse" protocolext="" au="0"> <request caid="0000" srvid="0000" ecmtime="0" answered=""></request> <times login="2011-01-28T16:00:17+0100" online="643" idle="630"></times> <connection ip="127.0.0.1" port="0">CARDOK</connection> </client> <client type="r" name="my_reader_2" protocol="mouse" protocolext="" au="0"> <request caid="0000" srvid="0000" ecmtime="0" answered=""></request> <times login="2011-01-28T16:00:17+0100" online="643" idle="629"></times> <connection ip="127.0.0.1" port="0">CARDOK</connection> </client> <client type="r" name="my_reader_3" protocol="mouse" protocolext="" au="0"> <request caid="0000" srvid="0000" ecmtime="0" answered=""></request> <times login="2011-01-28T16:00:17+0100" online="643" idle="630"></times> <connection ip="127.0.0.1" port="0">CARDOK</connection> </client> <client type="c" name="cccam_2" protocol="newcamd (CCcam)" protocolext="" au="0"> <request caid="FFFE" srvid="FFFE" ecmtime="0" answered=""></request> <times login="2011-01-28T16:00:33+0100" online="627" idle="58"></times> <connection ip="127.0.0.1" port="43111">OK</connection> </client> <client type="c" name="cccam_3" protocol="newcamd (CCcam)" protocolext="" au="0"> <request caid="1702" srvid="00CA" ecmtime="0" answered="invalid"></request> <times login="2011-01-28T16:00:33+0100" online="627" idle="23"></times> <connection ip="127.0.0.1" port="33222">OK</connection> </client> <client type="c" name="cccam_1" protocol="newcamd (CCcam)" protocolext="" au="0"> <request caid="1702" srvid="00CA" ecmtime="1" answered="invalid"></request> <times login="2011-01-28T16:00:56+0100" online="604" idle="23"></times> <connection ip="127.0.0.1" port="40333">OK</connection> </client> </status> <log><![CDATA[]]></log>
</oscam> </syntaxhighlight>
Readerstatus mit EMM und LB Stats /oscamapi.html?part=readerstats&label=<readername> <syntaxhighlight lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <oscam version="1.00-unstable_svn build #4641" starttime="2011-01-28T16:00:17+0100" uptime="1718" >
<reader label="my_reader_1"> <emmstats totalwritten="4" totalskipped="0" totalblocked="0" totalerror="0"> <emm type="unknown" result="error">0</emm> <emm type="unique" result="error">0</emm> <emm type="shared" result="error">0</emm> <emm type="global" result="error">0</emm> <emm type="unknown" result="written">0</emm> <emm type="unique" result="written">0</emm> <emm type="shared" result="written">0</emm> <emm type="global" result="written">4</emm> <emm type="unknown" result="skipped">0</emm> <emm type="unique" result="skipped">0</emm> <emm type="shared" result="skipped">0</emm> <emm type="global" result="skipped">0</emm> <emm type="unknown" result="blocked">0</emm> <emm type="unique" result="blocked">0</emm> <emm type="shared" result="blocked">0</emm> <emm type="global" result="blocked">0</emm> </emmstats> <ecmstats count="1" totalecm="68" lastaccess="2011-01-28T16:28:52+0100"> <ecm caid="1702" provid="000000" srvid="00DF" channelname="Bundesliga" avgtime="541" lasttime="543" rc="0" rcs="found" lastrequest="2011-01-28T16:28:52+0100">68</ecm> </ecmstats> </reader>
</oscam> </syntaxhighlight>
User statistics /oscamapi.html?part=userstats&label=<username> <syntaxhighlight lang="xml">
<?xml version="1.0" encoding="UTF-8"?> <oscam version="1.00-unstable_svn build #4840" revision="4840" starttime="2011-03-19T17:52:41+0000" uptime="1872" > <users> <user name="tm800"> <stats> <cwok>238</cwok> <cwnok>10</cwnok> <cwignore>6</cwignore> <cwtimeout>0</cwtimeout> <cwcache>0</cwcache> <cwtun>0</cwtun> <cwlastresptime>109</cwlastresptime> <emmok>0</emmok> <emmnok>0</emmnok> <cwrate>7.49</cwrate> </stats> </user> </users> <totals> <cwok>597</cwok> <cwnok>10</cwnok> <cwignore>6</cwignore> <cwtimeout>0</cwtimeout> <cwcache>0</cwcache> <cwtun>0</cwtun> </totals> </oscam>
</syntaxhighlight>
XML-Parsing: PHP-Beispiel
<syntaxhighlight lang="php"> <?php
- OSCam XML API example in PHP
- USER SETUP ***********************************************
$_CONSTANTS = array(
'OSCAM_URL' => 'http://127.0.0.1:4711/oscamapi.html' ,'LOCAL_ACCESS_ONLY' => true # true = call OSCam XML API by "wget"; false = call OSCam XML API by URL - default = true ,'NL' => "\n" # Newline
);
- END USER SETUP *******************************************
- define constants *****************************************
foreach($_CONSTANTS as $key => $val) {
if(is_array($_CONSTANTS[$key])) $$key = $val; else define($key, $val);
}
- save memory...
unset($_CONSTANTS);
- private vars *********************************************
define('PART_NAME', 'part');
- OSCam class **********************************************
class OSCam {
public function getXMLfile($part) { $r = null; if(LOCAL_ACCESS_ONLY) { $r = trim(shell_exec('wget -O - "'.OSCAM_URL.'?'.PART_NAME.'='.$part.'"')); } else { $r = file_get_contents(OSCAM_URL.'?'.PART_NAME.'='.$part); } return $r; }
public function getStatusNumOfType(&$xml, $nType) { $r = 0; $x = new SimpleXMLElement($xml); foreach($x->status->client as $c) { if(!empty($c['type']) && $c['type'] == $nType) $r++; } return $r; }
}
- OUTPUT-EXAMPLES ******************************************
$oc = new OSCam;
- status
$xml = $oc->getXMLfile('status');
echo NL.'
XML status content:
'.NL; echo '
'.htmlspecialchars($xml).'
'; echo NL.'
Number of readers:
'.NL;
$t = $oc->getStatusNumOfType($xml, 'r');
echo '
'.$t.'
'; echo NL.'
Number of active clients:
'.NL;
$t = $oc->getStatusNumOfType($xml, 'c');
echo '
'.$t.'
';
?> </syntaxhighlight>
Diese Seite in anderen Sprachen - This page in other languages - Cette page dans d'autres langues - Queste pagine in altre Lingue
[[OSCam/de/{{#titleparts:OSCam/de/XML_API|3|3}}|Deutsch]] [[OSCam/en/{{#titleparts:OSCam/de/XML_API|3|3}}|English]] [[OSCam/fr/{{#titleparts:OSCam/de/XML_API|3|3}}|Français]] [[OSCam/it/{{#titleparts:OSCam/de/XML_API|3|3}}|Italiano]]