PHP Classes

File: examples/test-xml-rpc.php

Recommend this page to a friend!
  Packages of Marcel Kohls   Very Simple API   examples/test-xml-rpc.php   Download  
File: examples/test-xml-rpc.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Very Simple API
Implement REST APIs using service classes
Author: By
Last change:
Date: 9 years ago
Size: 797 bytes
 

Contents

Class file image Download
<?php
    $method = "POST"; // DELETE, GET, PATCH, POST,
    $request = xmlrpc_encode_request("methodName", array("methodParam"=>"param1", "otherMethodParam"=>"param2 with spaces"));
    $context = stream_context_create(array('http' => array(
        'method' => $method,
        'header' => "Content-Type: text/xml",
        'content' => $request
    )));

    // sample using unique Id on URL (PATCH, DELETE)
    // $file = file_get_contents("http://localhost/vsapi/api/v1/Ping/12345", false, $context);

    $file = file_get_contents("http://localhost/vsapi/api/v1/Ping", false, $context);
    $response = xmlrpc_decode($file);

    if (xmlrpc_is_fault($response)) {
        trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
    } else {
        print_r($response);
    }