![]() ![]() ![]() ![]() ![]() |
![]() |
Support for the Blue Alligator applications
You are not logged in.
Hi I wrote a php script to upload data to web service. Everything is working fine files which I am sending are one Cloud server, but response from yours server looks incomplete this is example of my code:
this is function which I am using to upload data
function cloud_upload($url,$upl_data){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $upl_data); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml')); $response = curl_exec($ch); $status = curl_getinfo($ch); curl_close ($ch); return $response; }
this is how I call function
$x = cloud_upload($url,$cloud); $json = json_encode($x); echo "var_dump result<br/>"; var_dump($json); echo "<br/><br/>print_r result<br/>"; print_r($json);
and results which I get
var_dump result string(111) ""0<\/code>Upload file ok<\/message><\/result>"" print_r result "0<\/code>Upload file ok<\/message><\/result>"
It's look that
<result> and <code> is missing.
Question is am I doing something wrong or this response is incomplete.
Offline
The full response you're getting in this instance is:
<result><code>0</code><message>Upload file ok</message></result>
However, it looks like the opening element names are being removed at your end (including the "message" name, possibly by the $json_encode call. what was the value of $x?) so you're left with
0</code>Upload file ok</message></result>
Offline
echo $x;
or
print_r($x);
gives me
0Upload file ok
I am not able to get clean xml respond like you have in yours examples, maybe it's cURL fault
Last edited by art (2014-01-07 20:54:28)
Offline
It may be the fault of "cURL", we are not familiar with it.
If the response was only missing the beginning and/or end then it would indicate that it was incomplete, but in your instance "<message>" is also missing from the middle of the response which indicates to us that it's being altered in some way after it has been received.
Offline
Apple, the Apple logo, iPod, iPod touch, iPad and iTunes are trademarks of Apple Inc., registered in the U.S. and other countries. iPhone is a trademark of Apple Inc. App Store is a service mark of Apple Inc. |