PHP Classes
elePHPant
Icontem

File: samples/index.php

Recommend this page to a friend!
  Classes of Tom Schaefer  >  QTransfer  >  samples/index.php  >  Download  
File: samples/index.php
Role: Example script
Content type: text/plain
Description: sample
Class: QTransfer
Send HTTP requests and process XML responses
Author: By
Last change: add
Date: 9 years ago
Size: 911 bytes
 

Contents

Class file image Download
<?php

include_once 'config.inc.php';

// sends a request xml via curl to a server application
// and receives the response as xml
$c = Transfer_Curl::getInstance()
            ->
doPostXML(
           
"http://www.query4u.de/test/index.php",
           
'<?xml version="1.0" encoding="UTF-8"?>
<transfer>
    <head>
        <context>Test</context>
        <module>Module</module>
        <action>index</action>
        <checksum>'
.Transfer_Checksum::build("none","Test","Module","index").'</checksum>
        <format>xml</format>
        <version>0.1.1</version>
    </head>
    <body>
    </body>
</transfer>
'
);


// transforms and validates the response against a schema
$response = new Transfer_XmlResponse("Test","Module","index");
$response->setSchema("response");
$response->setOutput($c);
$response->render();

if(
$response->isValid()) {
   
header("content-type: text/xml");
    echo
$response->getXml();
} else {
    echo
"invalid request";
}