当前位置: 首页>>代码示例>>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;未经允许,请勿转载。