PHP

XMLRPC example

CK CK 3788 
Created at
Updated at  
761 0 0

XML-RPC (XML Remote Procedure Call) is a remote procedure call protocol that uses XML to encode data and HTTP to send it over a network. It allows programs running on different systems to communicate with each other by invoking procedures on a remote server. Essentially, it enables you to send requests and receive responses in a standardized way, regardless of the programming language or operating system used. This makes it ideal for building distributed applications where different systems need to exchange data and functionality. 

 

Following is the simple XMLRPC example showing the usage.

 

<html>
<head>
<title>XML-RPC PHP Demo</title>
</head>
<body>
<h1>XML-RPC PHP Demo</h1>

<?php
include 'xmlrpc.inc';

// Make an object to represent our server.
$server = new xmlrpc_client('/api/sample.php',
                            'xmlrpc-c.sourceforge.net', 80);

// Send a message to the server.
$message = new xmlrpcmsg('sample.sumAndDifference',
                         array(new xmlrpcval(5, 'int'),
                               new xmlrpcval(3, 'int')));
$result = $server->send($message);

// Process the response.
if (!$result) {
    print "<p>Could not connect to HTTP server.</p>";
} elseif ($result->faultCode()) {
    print "<p>XML-RPC Fault #" . $result->faultCode() . ": " .
        $result->faultString();
} else {
    $struct = $result->value();
    $sumval = $struct->structmem('sum');
    $sum = $sumval->scalarval();
    $differenceval = $struct->structmem('difference');
    $difference = $differenceval->scalarval();
    print "<p>Sum: " . htmlentities($sum) .
        ", Difference: " . htmlentities($difference) . "</p>";
}
?>

</body>
</html>
Tags PHP XML-RPC PHP Demo connection blocking get random value by SQL get referer URL Facebook X
Comments 0
Similar posts
  1. How to upload attachments such as image by metaWeblog API ?
    391
  2. How to post blog content by metaweblog API ?
    486
  3. How to block a connection from the certain site ?
    350
  4. File downloading via HTTP
    445
  5. How to extract file name from given URL ?
    443
  6. How to download a file from a certain URL to server ?
    419
  7. Posting to a Wordpress Blog Via XMLRPC Using Blogger API
    763
  8. ISO 8601 format time format string conversion
    534
  9. HTML redirection in PHP
    398
  10. Get the actual filesize for a size above 2GB in Windows
    427
  11. How to convert W3C Date Time Format ?
    453
  12. foreach loop
    443
  13. Can PHP switch in strings ?
    391
  14. PHP Switch Example
    427
  15. How to send email in PHP ?
    889
  16. How to pass variables via url
    468
  17. How to declare array in PHP like C/C++
    670
  18. PHP date and time formatting
    428
  19. How to redirect browser in PHP ?
    484
  20. How to get current filename as variable ?
    768
  21. email validation, simple
    412
  22. How to ban / block IP addresses
    509
  23. for loop - simple
    449
  24. form action - detect form post
    428
  25. How to make random number ?
    517
  26. How to force cookies, disable php sessid in URL ?
    555
  27. How to check if a file exists ?
    786
  28. How to include a file with error reporting ?
    428
  29. PHP if...else... example
    445
  30. PHP form handling example in single page
    415
  1. Get Remote IP Address in PHP
    494
  2. How to remove HTML tags in text string?
    405
  3. Directory listing in PHP
    511
  4. Seconds to String in PHP
    435
  5. How to delete file on certain path ?
    388
  6. ASCII Artwork Generator from image file
    469
  7. How to limit by Timeout when opening URL ?
    457
  8. How to put timeout when opening URL by fopen ?
    440
  9. How to convert W3C Date Time Format ?
    453
  10. Get the actual filesize for a size above 2GB in Windows
    427
  11. HTML redirection in PHP
    398
  12. ISO 8601 format time format string conversion
    534
  13. How to download a file from a certain URL to server ?
    419
  14. How to extract file name from given URL ?
    443
  15. File downloading via HTTP
    445
  16. How to upload attachments such as image by metaWeblog API ?
    391
  17. How to post blog content by metaweblog API ?
    486
  18. Posting to a Wordpress Blog Via XMLRPC Using Blogger API
    763
  19. foreach loop
    443
  20. Can PHP switch in strings ?
    391
  21. PHP Switch Example
    427
  22. How to send email in PHP ?
    889
  23. How to pass variables via url
    468
  24. How to declare array in PHP like C/C++
    670
  25. PHP date and time formatting
    428
  26. How to redirect browser in PHP ?
    484
  27. How to get current filename as variable ?
    768
  28. email validation, simple
    412
  29. How to ban / block IP addresses
    509
  30. for loop - simple
    449
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,732
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    86
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    198
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    509
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    234
  17. The Concept of Scaffolding in AI Agents
    222
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    576
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    253
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    328
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252