當前位置: 首頁>>代碼示例>>PHP>>正文


PHP xmlrpcmsg::parseResponse方法代碼示例

本文整理匯總了PHP中xmlrpcmsg::parseResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP xmlrpcmsg::parseResponse方法的具體用法?PHP xmlrpcmsg::parseResponse怎麽用?PHP xmlrpcmsg::parseResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xmlrpcmsg的用法示例。


在下文中一共展示了xmlrpcmsg::parseResponse方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: callTamburine

 function callTamburine($method, $params)
 {
     global $config;
     if (!is_array($params)) {
         $params = array($params);
     }
     // fetch config
     $urlParts = parse_url($config['tamburineURL']);
     $port = $urlParts['port'];
     $host = $urlParts['host'];
     $path = $urlParts['path'];
     //debug("host", $host);
     //debug("port", $port);
     //debug("path", $path);
     /*
     // xmlrpc encode parameters
     for($i=0;$i<count($params);$i++){
       if(get_class($params[$i]) != 'xmlrpcval') {
         $xmlparams[$i] = xmlrpc_encoder($params[$i]);
       }
     }
     $msg = new xmlrpcmsg($method, $xmlparams);
     // this does not work because it rawurlencodes string values
     // and Tamburine does not understand it
     $rawMessage = $msg->serialize();
     */
     $rawMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<methodCall>\n<methodName>{$method}</methodName>\n<params>";
     for ($i = 0; $i < count($params); $i++) {
         $rawMessage .= "\n<param><value>";
         $value = trim($params[$i]);
         if (is_numeric($value)) {
             $rawMessage .= "<i4>{$value}</i4>";
         } else {
             $rawMessage .= "<string>{$value}</string>";
         }
         $rawMessage .= "</value></param>";
     }
     $rawMessage .= "\n</params>\n</methodCall>";
     //prepare request header
     $header = "POST {$path} HTTP/1.1\nAccept: */*\nAccept-Encoding: deflate\nTE: trailers,deflate\nHost: {$host}:{$port}\nUser-Agent: Tamburine/0.2 libwww/5.4.0\nConnection: TE,Keep-Alive\nDate: Tue, 17 Jun 2003 08:59:10 GMT\nContent-Length: " . strlen($rawMessage) . "\nContent-Type: text/xml\n\n";
     $fp = fsockopen($host, $port, $errno, $errstr, $this->timeout);
     if (!$fp) {
         raiseError("Streaming error: {$errstr} ({$errno})");
     }
     if (!socket_set_timeout($fp, $this->timeout)) {
         logError("could not set coket timeout");
     }
     if (!fputs($fp, $header, strlen($header))) {
         raiseError('Streaming error: Write error');
     }
     fflush($fp);
     debug("FLUSH", 1);
     if (!fputs($fp, $rawMessage, strlen($rawMessage))) {
         raiseError('Streaming error: Write error');
     }
     //fflush($fp);
     debug("SENT ALL", 1);
     while (!feof($fp)) {
         $rep = fread($fp, 1024);
         if ($rep === FALSE) {
             raiseError('Streaming error: Read error');
         }
         $rawReply .= $rep;
     }
     fclose($fp);
     $parts = explode("\n\n", $rawReply);
     if (count($parts) > 2) {
         raiseError("could not parse response");
     }
     $header = $parts[0];
     $content = $parts[1];
     $content = preg_replace('/<\\?.*\\?>/', '', $content);
     $msg = new xmlrpcmsg('foo', '');
     $resp = $msg->parseResponse($content);
     //dump($resp->value(), "RETVAL1");
     $retval = xmlrpc_decoder($resp->value());
     return $retval;
 }
開發者ID:BackupTheBerlios,項目名稱:sotf-svn,代碼行數:78,代碼來源:rpc_Utils.class.php

示例2: xmlrpcmsg

    function testUTF8Response()
    {
        $s = new xmlrpcmsg('dummy');
        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode('àüèàüè') . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
';
        $r = $s->parseResponse($f, false, 'phpvals');
        $v = $r->value();
        $v = $v['content'];
        $this->assertEquals("àüèàüè", $v);
        $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode('àüèàüè') . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
';
        $r = $s->parseResponse($f, false, 'phpvals');
        $v = $r->value();
        $v = $v['content'];
        $this->assertEquals("àüèàüè", $v);
    }
開發者ID:RiquelmyMelara,項目名稱:Awakened-Millionaire,代碼行數:18,代碼來源:testsuite.php

示例3: testValidNumbers

    function testValidNumbers()
    {
        $m = new xmlrpcmsg('dummy');
        $fp = '<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member> 
<name>integer1</name>
<value><int>01</int></value>
</member>
<member> 
<name>float1</name>
<value><double>01.10</double></value>
</member>
<member> 
<name>integer2</name>
<value><int>+1</int></value>
</member>
<member> 
<name>float2</name>
<value><double>+1.10</double></value>
</member>
<member>
<name>float3</name>
<value><double>-1.10e2</double></value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>';
        $r = $m->parseResponse($fp);
        $v = $r->value();
        $s = $v->structmem('integer1');
        $t = $v->structmem('float1');
        $u = $v->structmem('integer2');
        $w = $v->structmem('float2');
        $x = $v->structmem('float3');
        $this->assertEquals(1, $s->scalarval());
        $this->assertEquals(1.1, $t->scalarval());
        $this->assertEquals(1, $u->scalarval());
        $this->assertEquals(1.1, $w->scalarval());
        $this->assertEquals(-110.0, $x->scalarval());
    }
開發者ID:bitweaver,項目名稱:xmlrpc_lib,代碼行數:47,代碼來源:testsuite.php


注:本文中的xmlrpcmsg::parseResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。