コード例 #1
0
            
       	    $soapRequest = ZuoraAPIHelper::createRequestAndHeadersWithNS($header->data["session"], $_SESSION['api-batchSize'], $callOptions, $payload, $_SESSION['api-ns'], $_SESSION['object-ns']);
       	    $requestString = xml_pretty_printer($soapRequest, true);

            $timeBefore = microtime(true);
	    $xml = ZuoraAPIHelper::callAPIWithClient($client, $header, $soapRequest, $debug);
            $timings[] = microtime(true) - $timeBefore;
	    $xml_obj = ZuoraAPIHelper::getElementFromXML($xml);

	    $uniqueHeaders = array();
       	    if ($outputCSV) {
       	    	header("Content-type: application/vnd.ms-excel");
       	    	header("Content-disposition: csv; filename=document_" . date("Ymd") . ".csv");

		// Get the headers.
                $uniqueHeaders = ZuoraAPIHelper::getCSVHeaders($xml_obj);

	        ZuoraAPIHelper::getCSVData($xml_obj, $uniqueHeaders, true, true);
       	    } else {
       	    	$responseString = xml_pretty_printer($xml, true);
       	    }

	    $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);
コード例 #2
0
 public static function convertXMLtoCSV($xml, $print, $headers)
 {
     $xml_obj = ZuoraAPIHelper::getElementFromXML($xml);
     $uniqueHeaders = ZuoraAPIHelper::getCSVHeaders($xml_obj);
     return ZuoraAPIHelper::getCSVData($xml_obj, $uniqueHeaders, $print, $headers);
     /* Old code.
             global $defaultApiNamespace;
             global $defaultObjectNamespace;
             global $defaultApiNamespaceURL;
             global $defaultObjectNamespaceURL;
     	global $SEPARATOR;
     	global $TEXT_QUALIFIER;
     	$SPECIAL_FIELDS = array("Id");
     
             $xml_obj = new SimpleXMLElement($xml);
             $xml_obj->registerXPathNamespace($defaultApiNamespace,$defaultApiNamespaceURL);
             $xml_obj->registerXPathNamespace($defaultObjectNamespace,$defaultObjectNamespaceURL);
             $labels = $xml_obj->xpath("//" . $defaultApiNamespace . ":records/*");
             $resultRecords = $xml_obj->xpath("//" . $defaultApiNamespace . ":records");
             $retList = array();
     
             #Determine headers.
     	$found = false;
     	$uniqueHeaders = array();
     	foreach ($labels as $node) {
     	    $value = $node[0]->getName();
     	    if (strlen($value) > 0 && !in_array($value, $uniqueHeaders)) {
     	        if (in_array($value, $SPECIAL_FIELDS)) {
     		    $found = true;
     		} else {
     	            $uniqueHeaders[] = $value;
     		}
     	    }
     	}
     	sort($uniqueHeaders);
     	if ($found) {
     	    foreach ($SPECIAL_FIELDS as $field) {
     	        array_unshift($uniqueHeaders, $field);
                 }
     	}
     
     	#Fill in the data.
     	$output = implode($SEPARATOR, $uniqueHeaders) . "\n";
     	if ($print) {
     	    print $output;
     	    $output = "";
     	}
     	for ($i = 0; $i < count($resultRecords); $i++) {
     	    $index = 0;
     	    foreach ($uniqueHeaders as $header) {
     	    	if ($index > 0) {
     		    $output .= $SEPARATOR;
     		}
     	        $attr = $xml_obj->xpath("//" . $defaultApiNamespace . ":records[position()=" . ($i+1) . "]/" . $defaultObjectNamespace . ":" . $header);
     		$value = $attr[0];
     		if ($value) {
     		   // Previously checked if the SEPARATOR character was in the data, but now just escaping by default.
     		   $output .= $TEXT_QUALIFIER . $value . $TEXT_QUALIFIER;
     		}
     		$index++;
     	    }
     	    $output .= "\n";
     	    if ($print) {
     	        print $output;
     		$output = "";
     	    }
     	}
     	return $output;
     */
 }