PHP's Enterprise Application-webservice

Source: Internet
Author: User
Tags split strlen

Ping Service, blog program provides a notification mechanism for the first time to post updates to the blog to provide ping service services site, write the aggregation of the time studied

Look at the standard first.

This is a standard ping Service, with XMLRPC to pass the data, comments written in such detail, the code instructions do not need it, PHP5 open Xmlrpc method

client.php

<?php
$host = ' ZXSV ';
$port = 80;
$rpc _server = '/test/xmlrpc_server.php ';
$title = ' ZXSV ';
$server = ' http://zxsv/test/';
$rss = ' http://zxsv/test/rss.php ';
Weblogupdates.ping method
$Ping = xmlrpc_encode_request (' weblogupdates.ping ', Array ($title, $server));
Weblogupdates.extendedping method
$extendedPing = xmlrpc_encode_request (' weblogupdates.extendedping ', Array ($title, $server, $rss));
Call the Rpc_client_call function to send all requests to the XML-RPC server to get information
$response = Rpc_client_call ($host, $port, $rpc _server, $Ping);
$split = ' <?xml version= ' 1.0 ' encoding= ' iso-8859-1 '?> ';
$xml = Explode ($split, $response);
$xml = $split. Array_pop ($xml);
$response = Xmlrpc_decode ($xml);
Output information obtained from the RPC server side
Print_r ($response);
/**
* Functions: Functions provided to clients to connect XML-RPC server-side
Parameters
* $host hosts that need to be connected
* $port Port connecting the host
* $RPC _server XML-RPC server-side files
* $request encapsulated XML Request information
* Return: The connection successfully returned the XML information returned by the server side and failed to return false
*/
function Rpc_client_call ($host, $port, $rpc _server, $request) {
$fp = Fsockopen ($host, $port);
$query = "POST $rpc _server http/1.0\nuser_agent:xml-rpc client\nhost:". $host. " \ncontent-type:text/xml\ncontent-length: ". strlen ($request)." \ n ". $request." \ n ";
if (!fputs ($fp, $query, strlen ($query)) {
$ERRSTR = "Write error";
return false;
}
$contents = ';
while (!feof ($fp)) {
$contents. = Fgets ($FP);
}
Fclose ($FP);
return $contents;
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.