当前位置: 首页>>代码示例>>PHP>>正文


PHP XML_RPC_Message::createPayload方法代码示例

本文整理汇总了PHP中XML_RPC_Message::createPayload方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_RPC_Message::createPayload方法的具体用法?PHP XML_RPC_Message::createPayload怎么用?PHP XML_RPC_Message::createPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_RPC_Message的用法示例。


在下文中一共展示了XML_RPC_Message::createPayload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

     */
    require_once 'XML/RPC.php';
} else {
    if (substr(dirname(__FILE__), -9, -6) != 'XML') {
        echo "The parent directory must be named 'XML'.\n";
        exit;
    }
    ini_set('include_path', '../../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path'));
    /**
     * Get the needed class from the parent directory
     */
    require_once '../RPC.php';
}
$input = "First lfs\n\nSecond crlfs\r\n\r\nThird crs\r\rFourth line";
$expect_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<methodCall>\n\n<methodName>nada</methodName>\n\n<params>\n\n<param>\n\n<value><string>First lfs\n\nSecond crlfs\n\nThird crs\n\nFourth line</string></value>\n\n</param>\n\n</params>\n\n</methodCall>\n\n";
$expect_not_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<methodCall>\n\n<methodName>nada</methodName>\n\n<params>\n\n<param>\n\n<value><string>First lfs\n\n\n\nSecond crlfs\n\n\n\nThird crs\n\n\n\nFourth line</string></value>\n\n</param>\n\n</params>\n\n</methodCall>\n\n";
$msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input)));
$msg->createPayload();
if ($msg->payload == $expect_removed) {
    echo "passed\n";
} else {
    echo "PROBLEM\n";
}
$msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input)));
$msg->remove_extra_lines = false;
$msg->createPayload();
if ($msg->payload == $expect_not_removed) {
    echo "passed\n";
} else {
    echo "PROBLEM\n";
}
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:31,代码来源:extra-lines.php

示例2: switch


//.........这里部分代码省略.........
&nbsp;&nbsp;</label><br />
<?php 
                    }
                    ?>
                            <input onclick="<?php 
                    echo $noneclick;
                    ?>
" class="input_checkbox" style="margin: 0px; padding: 0px; vertical-align: bottom;" type="checkbox" value="none" id="serendipity[announce_entries_none]" />
                                <label title="<?php 
                    echo NONE;
                    ?>
" style="vertical-align: bottom; margin: 0px; padding: 0px;" for="serendipity[announce_entries_none]">&nbsp;<?php 
                    echo NONE;
                    ?>
&nbsp;&nbsp;</label><br />
                    </fieldset>
<?php 
                    return true;
                    break;
                case 'backend_publish':
                    if (!class_exists('XML_RPC_Base')) {
                        include_once S9Y_PEAR_PATH . "XML/RPC.php";
                    }
                    // First cycle through list of services to remove superseding services which may have been checked
                    foreach ($this->services as $index => $service) {
                        if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) {
                            $supersedes = explode(', ', $service['supersedes']);
                            foreach ($supersedes as $sid => $servicename) {
                                // A service has been checked that is superseded by another checked meta-service. Remove that service from the list of services to be ping'd
                                unset($serendipity['POST']['announce_entries_' . $servicename]);
                            }
                        }
                    }
                    foreach ($this->services as $index => $service) {
                        if (isset($serendipity['POST']['announce_entries_' . $service['name']]) || defined('SERENDIPITY_IS_XMLRPC') && serendipity_db_bool($this->get_config($service['name']))) {
                            if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) {
                                printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...', $service['host']);
                            }
                            flush();
                            # XXX append $serendipity['indexFile'] to baseURL?
                            $args = array(new XML_RPC_Value($serendipity['blogTitle'], 'string'), new XML_RPC_Value($serendipity['baseURL'], 'string'));
                            if ($service['extended']) {
                                # the checkUrl: for when the main page is not really the main page
                                $args[] = new XML_RPC_Value('', 'string');
                                # the rssUrl
                                $args[] = new XML_RPC_Value($serendipity['baseURL'] . 'rss.php?version=2.0', 'string');
                            }
                            $message = new XML_RPC_Message($service['extended'] ? 'weblogUpdates.extendedPing' : 'weblogUpdates.ping', $args);
                            $client = new XML_RPC_Client(trim($service['path']), trim($service['host']));
                            # 15 second timeout may not be long enough for weblogs.com
                            $message->createPayload();
                            $options = array();
                            serendipity_plugin_api::hook_event('backend_http_request', $options, 'weblogping');
                            serendipity_request_start();
                            $req = new HTTP_Request("http://" . $service['host'] . $service['path'], $options);
                            $req->setMethod(HTTP_REQUEST_METHOD_POST);
                            $req->addHeader("Content-Type", "text/xml");
                            if (strtoupper(LANG_CHARSET) != 'UTF-8') {
                                $payload = utf8_encode($message->payload);
                            } else {
                                $payload = $message->payload;
                            }
                            $req->addRawPostData($payload);
                            $http_result = $req->sendRequest();
                            $http_response = $req->getResponseBody();
                            $xmlrpc_result = $message->parseResponse($http_response);
                            if ($xmlrpc_result->faultCode()) {
                                $out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "<br />", htmlspecialchars($xmlrpc_result->faultString()));
                            } else {
                                $out = PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "<br />";
                            }
                            serendipity_request_end();
                            if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) {
                                echo $out;
                            }
                        }
                    }
                    return true;
                    break;
                case 'external_plugin':
                    if ($eventData == 'xmlrpc_ping') {
                        echo "XMLRPC START\n";
                        @define('SERENDIPITY_IS_XMLRPC', true);
                        @define('SERENDIPITY_XMLRPC_VERBOSE', true);
                        $this->event_hook('backend_publish', $bag, $eventData);
                        echo "XMLRPC DONE\n";
                    }
                    return true;
                case 'frontend_display':
                case 'backend_insert':
                case 'backend_update':
                case 'backend_draft':
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:serendipity_event_weblogping.php

示例3: sendPayloadHTTP10

 /**
  * Transmit the RPC request via HTTP 1.0 protocol
  * Requests should be sent using XML_RPC_Client send() rather than
  * calling this method directly.
  *
  * @param XML_RPC_Message $msg      the XML_RPC_Message object
  * @param string          $server   the server to send the request to
  * @param int             $port     the server port send the request to
  * @param int             $timeout  how many seconds to wait for the request
  *                                  before giving up
  * @param string          $userName a user name for accessing the RPC server
  * @param string          $password a password for accessing the RPC server
  * @return XML_RPC_Response|int 0 is returned if any problems happen.
  * @see XML_RPC_Client::send()
  */
 protected function sendPayloadHTTP10(XML_RPC_Message $msg, $server, $port, $timeout = 0, $userName = '', $password = '')
 {
     // Preemptive BC hacks for fools calling sendPayloadHTTP10() directly
     if ($userName != $this->userName) {
         $this->setCredentials($userName, $password);
     }
     // Only create the payload if it was not created previously
     if (empty($msg->payload)) {
         $msg->createPayload();
     }
     $this->createHeaders($msg);
     $op = $this->headers . "\r\n\r\n";
     $op .= $msg->payload;
     if ($this->debug) {
         echo "\n<pre>---SENT---\n";
         echo $op;
         echo "\n---END---</pre>\n";
     }
     /*
      * If we're using a proxy open a socket to the proxy server
      * instead to the xml-rpc server
      */
     if ($this->proxy) {
         if ($this->proxyProtocol === 'http://') {
             $protocol = '';
         } else {
             $protocol = $this->proxyProtocol;
         }
         if ($timeout > 0) {
             $fp = @fsockopen($protocol . $this->proxy, $this->proxyPort, $this->errNo, $this->errString, $timeout);
         } else {
             $fp = @fsockopen($protocol . $this->proxy, $this->proxyPort, $this->errNo, $this->errString);
         }
     } else {
         if ($this->protocol === 'http://') {
             $protocol = '';
         } else {
             $protocol = $this->protocol;
         }
         if ($timeout > 0) {
             $fp = @fsockopen($protocol . $server, $port, $this->errNo, $this->errString, $timeout);
         } else {
             $fp = @fsockopen($protocol . $server, $port, $this->errNo, $this->errString);
         }
     }
     /*
      * Just raising the error without returning it is strange,
      * but keep it here for backwards compatibility.
      */
     if (!$fp && $this->proxy) {
         $this->raiseError('Connection to proxy server ' . $this->proxy . ':' . $this->proxyPort . ' failed. ' . $this->errString, XML_RPC_ERROR_CONNECTION_FAILED);
         return 0;
     } elseif (!$fp) {
         $this->raiseError('Connection to RPC server ' . $server . ':' . $port . ' failed. ' . $this->errString, XML_RPC_ERROR_CONNECTION_FAILED);
         return 0;
     }
     if ($timeout) {
         /*
          * Using socket_set_timeout() because stream_set_timeout()
          * was introduced in 4.3.0, but we need to support 4.2.0.
          */
         socket_set_timeout($fp, $timeout);
     }
     if (!fputs($fp, $op, strlen($op))) {
         $this->errString = 'Write error';
         return 0;
     }
     $resp = $msg->parseResponseFile($fp);
     $meta = socket_get_status($fp);
     if ($meta['timed_out']) {
         fclose($fp);
         $this->errString = 'RPC server did not send response before timeout.';
         $this->raiseError($this->errString, XML_RPC_ERROR_CONNECTION_FAILED);
         return 0;
     }
     fclose($fp);
     return $resp;
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:93,代码来源:RPC.php


注:本文中的XML_RPC_Message::createPayload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。