QueueMetrics > Scripting QueueMetrics

XML-RPC Fails with Invalid method name format

(1/1)

avishnev:
I am using QM 1.7.0.2 and was trying to test XML-RPC interface by getting the Realtime stats. Starting with a sample php script in the manual for Stats, I modified it to look for Realtime blocks and inbound parameters. When I ran my script (see attached), I get Invalid method name response. the script is using robot user that is enabled in the system.

--- Code: ---<?php
require_once 'XML/RPC.php';
$qm_server = "209.124.166.74";  // the QueueMetrics server address
$qm_port   = "8080";       // the port QueueMetrics is running on
$qm_webapp = "queuemetrics";  // the webapp name for QueueMetrics

// set which response blocks we are looking for
$req_blocks = new XML_RPC_Value(array(
                        new XML_RPC_Value("RealtimeDO.RTRiassunto"),
                        new XML_RPC_Value("RealtimeDO.RTCallsBeingProc"),
                        new XML_RPC_Value("RealtimeDO.RTAgentsLoggedIn")
                ), "array");

// general invocation parameters - see the documentation
$params = array(
                new XML_RPC_Value("2253|1919|2222|5555|6666"),
                new XML_RPC_Value("robot"),
               new XML_RPC_Value("robot"),
                new XML_RPC_Value(""),
                new XML_RPC_Value(""),
                $req_blocks
       );

$msg = new XML_RPC_Message(’QM.realtime’, $params);
$cli = new XML_RPC_Client("/$qm_webapp/xmlrpc.do", $qm_server, $qm_port);
$cli->setDebug(9);
$resp = $cli->send($msg);
if (!$resp) {
    echo  "Communication error: ".$cli->errstr;
    exit;
}
if ($resp->faultCode()) {
    echo "Fault Code: ".$resp->faultCode() . "\n";
    echo "Fault Reason: ".$resp->faultString() . "\n";
} else {
    $val = $resp->value();
    $blocks = XML_RPC_decode($val);

    // now we print out the details....
    printBlock( "result", $blocks );
    printBlock( "RealtimeDO.RTRiassunto", $blocks );
    printBlock( "RealtimeDO.RTCallsBeingProc", $blocks );
    printBlock( "RealtimeDO.RTAgentsLoggedIn", $blocks );
}

// output a response block as HTML
function printBlock( $blockname, $blocks ) {
        echo "<h2>Response block: $blockname </h2>";
        echo "<table border=1>";
        $block = $blocks[$blockname];
        for ( $r = 0; $r < sizeof( $block ); $r++ ) {
                echo "<tr>";
                for ( $c = 0; $c < sizeof( $block[$r] ); $c++ ) {
                        echo( "<td>" . $block[$r][$c] . "</td>" );
                }
                echo "</tr>\n";
        }
        echo "</table>";
}
?>


--- End code ---

avishnev:
I solved my own problem. It appears that the call tom QM.realtime was in single quotes and it needed to be in double quotes. Once I changed it, I stopped getting the error and start getting data. However, the data is not correct. The response showed no data even though i selected the queue that asterisk showed with an agent. The agent was in a pause state. queue show cli command showed the agent, but XML-RPC did not. Can someone assist?

QueueMetrics:
Try something simple at first: while you are displaying the RT page, run a query for the very same queue and see if you get data.

Navigation

[0] Message Index

Go to full version