php - XML query to API returns 'Premature end of file' -



php - XML query to API returns 'Premature end of file' -

i trying phone call external site (api) homecoming xml response. have tried several ways of doing , end same response: premature end of file. unfortunately not able positive feedback other site. below php commands have tried , results. woud appear me there issue on other site. can re-create url , paste browser , works fine.

$url = "https://cli-cert.emdeon.com/servlet/xmlservlet?request=<?xml version='1.0'?>"; $url .= "<request userid='p_panda1' password='practice00' facility='3003154010'>"; $url .= "<object name='clinicalreport' op='search_filedelivery'>"; $url .= "<receivingorganization>3003154010</receivingorganization>"; $url .= "<creation_datetime_from>09/01/2014</creation_datetime_from>"; $url .= "<creation_datetime_to>10/10/2014</creation_datetime_to>"; $url .= "<is_downloaded>n</is_downloaded></object></request>"; $myxml = simplexml_load_file($url); echo "<pre>"; print_r($myxml); $postdata = file_get_contents($url); echo "<pre>"; print_r($postdata); $ch = curl_init($url); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $xml); curl_setopt($ch, curlopt_returntransfer, true); $response = curl_exec($ch); curl_close($ch); echo "<pre>"; echo $response,"<br>";

output echo commands:

simplexmlelement object ( [0] => premature end of file. ) premature end of file. premature end of file.

the url creating invalid.

you creating url like:

https://cli-cert.emdeon.com/servlet/xmlservlet?request=<?xml version='1.0'?>...

which mean have 2 questionmarks in it. illustration < not valid url character far know.

so have url-encode that, like:

$request = '<?xml version='1.0'?>...etc...'; $url = "https://cli-cert.emdeon.com/servlet/xmlservlet?request=". urlencode($request);

php xml parsing

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -