Ejemplo n.º 1
0
       	    	$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);

       	    	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();
       	}
    }
}
?>
Ejemplo n.º 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;
     */
 }