/** * http://ehsmeng.blogspot.com/2010/05/simple-php-xml-pretty-print-function.html * with the addition of URL hyperlink by Stuart Lewis */ function xml_pretty_printer($xml, $indent = 0) { if (is_string($xml)) { $xml = new SimpleXMLElement($xml); echo '<pre>', htmlspecialchars('<?xml version="1.0" encoding="utf-8"?>'); xml_pretty_printer($xml); echo '</pre>'; return; } echo "\n", str_pad('', $indent, ' '), '<<b>', $xml->getName(), '</b>'; foreach ($xml->attributes() as $k => $v) { if (substr($v, 0, 4) === 'http') { $v = '<a href="' . $v . '">' . htmlspecialchars($v) . '</a>'; } else { $v = htmlspecialchars($v); } echo ' ', $k, '="<i>' . $v . '</i>"'; } echo '>'; $any = false; foreach ($xml->children() as $k => $v) { xml_pretty_printer($v, $indent + 4); $any = true; } $val = (string) $xml; if ('' != $xml) { if (substr($val, 0, 4) === 'http') { $val = '<a href="' . $val . '">' . htmlspecialchars($val) . '</a>'; } else { $val - htmlspecialchars($val); } echo $any ? "\n" . str_pad('', $indent + 4, ' ') : '', '<i>', $val, '</i>'; } echo $any ? "\n" . str_pad('', $indent, ' ') : '', '</<b>', $xml->getName(), '</b>>'; }
$queryLocator = ZuoraAPIHelper::getQueryLocator($xml); while ($outputQM && $queryLocator) { $payload = "<ns1:queryMore><ns1:queryLocator>" . $queryLocator . "</ns1:queryLocator></ns1:queryMore>"; $soapRequest = ZuoraAPIHelper::createRequestAndHeadersWithNS($header->data["session"], $_SESSION['api-batchSize'], $callOptions, $payload, $_SESSION['api-ns'], $_SESSION['object-ns']); $timeBefore = microtime(true); $xml = ZuoraAPIHelper::callAPIWithClient($client, $header, $soapRequest, $debug); $timings[] = microtime(true) - $timeBefore; $queryLocator = ZuoraAPIHelper::getQueryLocator($xml); if ($outputCSV) { $xml_obj = ZuoraAPIHelper::getElementFromXML($xml); ZuoraAPIHelper::getCSVData($xml_obj, $uniqueHeaders, true, false); } else { $responseString .= "\n" . xml_pretty_printer($xml, true); $requestString .= "\n" . xml_pretty_printer($soapRequest, true); } } if ($outputCSV) { exit; } } catch (Exception $e) { $errorString = $e->getMessage(); } } } ?> <html> <head> <title>Z-Commerce API Utility</title>
$header = login($client, $username, $password, $debug); // Iterate through the data. $successCount = 0; $errorCount = 0; $resultArray = array(); $payloadChunks = array_chunk($payload, $logIndex); $chunkCount = 0; $recordCount = 0; foreach ($payloadChunks as $chunk) { $chunkCount++; # Create the XML for the operation/object. $xml = ZuoraAPIHelper::printXMLWithNS($operation, $object, $fieldList, $chunk, $debug, 0, $defaultApiNamespace, $defaultObjectNamespace, false); if ($showRequest) { $soapRequest = createRequest($header->data["session"], $xml); fwrite($lf, "Request:\n"); fwrite($lf, xml_pretty_printer($soapRequest, true) . "\n"); continue; } $result = ZuoraAPIHelper::bulkOperation($client, $header, $operation, $xml, count($chunk), $debug, TRUE, $objectCount); $successCount += $result["successCount"]; $errorCount += $result["errorCount"]; $resultArray[] = $result; $recordCount += count($chunk); // Print a Summary of results fwrite($lf, "Chunk " . $chunkCount . ", " . $recordCount . " records processed: successfully " . $operation . "d " . $result["successCount"] . " out of " . count($chunk) . " ZObjects. Number of errors: " . $result["errorCount"] . ". Total errors: " . $errorCount . "/" . $recordCount . ".\n"); if ($result["errorCount"] > 0) { fwrite($lf, "The following ZObjects failed:\n"); $errorList = $result["errorList"]; for ($i = 0; $i < count($errorList); $i++) { $error = $errorList[$i]; // Please note the offset by 1 for the header.
<input type="hidden" name="durl" value="<?php echo $collection->sac_href; ?> " /> <input type="hidden" name="nextform" value="../../post/atomentry" /> <input type="submit" value="Deposit an atom entry" /> </form> <?php } } ?> </div> <div class="section"> <h2>Response:</h2> <pre>Status code: <?php echo $response->sac_status; ?> </pre> <pre><?php echo xml_pretty_printer($response->sac_xml); ?> </pre> </div> <div id="footer"> <a href='../../'>Home</a> | Based on the <a href="http://github.com/stuartlewis/swordappv2-php-library/">swordappv2-php-library</a> </div> </body> </html>
<link rel='stylesheet' type='text/css' media='all' href='../../css/style.css' /> </head> <body> <div id="header"> <h1>SWORD v2 exerciser</h1> </div> <?php if (!empty($errormsg)) { ?> <div class="error"><?php echo $errormsg; ?> </div><?php } ?> <div class="section"> <h2>Response:</h2> <pre><?php echo xml_pretty_printer($response); ?> </pre> </div> <div id="footer"> <a href='../../'>Home</a> | Based on the <a href="http://github.com/stuartlewis/swordappv2-php-library/">swordappv2-php-library</a> </div> </body> </html>
if ($_REQUEST['oauth_params_loc'] == 'query') { $feedUri = $req->to_url(); $auth_header = null; } $content_type = $_POST['content-type']; $gdataVersion = 'GData-Version: ' . @$_REQUEST['gdata-version']; $result = send_signed_request($http_method, $feedUri, array($auth_header, $content_type, $gdataVersion), $postData); if (!$result) { die("{'html_link' : '" . $req->to_url() . "', " . "'base_string' : '" . $req->get_signature_base_string() . "', " . "'response' : '" . $result . "'}"); // return json } $result = split('<', $result, 2); // If response was not XML xml_pretty_printer() will throw exception. // In that case, set the response body directly from the result try { $response_body = @xml_pretty_printer(isset($result[1]) ? '<' . $result[1] : $result[0], true); } catch (Exception $e) { $response_body = isset($result[1]) ? '<' . $result[1] : $result[0]; } // <pre> tags needed for IE $response_body = '<pre>' . $response_body . '</pre>'; echo json_encode(array('html_link' => $req->to_url(), 'base_string' => $req->get_signature_base_string(), 'headers' => isset($result[1]) ? $result[0] : '', 'response' => $response_body, 'authorization_header' => $auth_header)); exit; break; // 'available feeds' button. Uses AuthSubTokenInfo to parse out feeds the token can access. // 'available feeds' button. Uses AuthSubTokenInfo to parse out feeds the token can access. case 'discovery': $url = 'https://www.google.com/accounts/AuthSubTokenInfo'; $req = OAuthRequest::from_consumer_and_token($consumer, $oauth_token, 'GET', $url); $req->sign_request($sig_method, $consumer, $oauth_token, $privKey); $response = send_signed_request('GET', $req);