API for PHP clients
While a toolset has not been made specifically for PHP, the following has been used to interact with ConcourseConnect.
In the example, the XML creation is left up to the application to implement, although an XML library is strongly encouraged so that the XML is encoded properly.
<? // Site to post to $server = "www.example.com" $path = "/connect/Service.do" // Begin the transfer $socket = fsockopen($server, 80); if (!$socket) { // error: could not connect to server // return } else { // Post the XML document $request = "POST " . $path . " HTTP/1.0\r\n" . "Host: " . $server . "\r\n" . "Content-Type: text/xml\r\n" . "Content-Length: " . strlen($xmlDocument) . "\r\n\r\n" . $xmlDocument; if (!fputs($socket, $request, strlen($request))) { // error: could not write to server // return } $response = ''; while ($data = fread($socket, 32768)) { $response .= $data; } fclose($socket); if ($response = '') { // error: no response from server // return } else { // review the response for status } } ?>
Some things to keep in mind...
- The XML needs to be well-formed to handle user-supplied characters correctly
- Errors in the response provide some answers; check both the client and server output
Sign in to add your comment.