PHP cURL not working for sending POST request to api -


i trying send post request sms api , receive feedback them using php , curl .but, curl not working me ,when try send same data through form works.

$post = array(             'data' => $xml1      ); $url = 'url'; $ch = curl_init(); curl_setopt( $ch, curlopt_url, $url ); curl_setopt( $ch, curlopt_post, true ); curl_setopt( $ch, curlopt_returntransfer, true ); curl_setopt( $ch, curlopt_postfields, $post ); curl_setopt($ch, curlinfo_header_out, true); $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); echo "<input type=\"textarea\" id=\"txt\"  style='width:600px' value='$result'></input>"; echo "<input type=\"textarea\" id=\"txt1\" name='data1' style='width:600px' value='".$info['request_header']."'></input>"; 

and xml is

<?xml version="1.0" encoding="iso-8859-1"?> <!doctype message system "http://127.0.0.1:80/psms/dtd/messagev12.dtd"> <message ver="1.2"> <user username="abc" password="pqr" /> <sms udh="0" coding="1" text="sms text" property="0" id="1" template="" emailtext="" attachment=""><address from="someone" to="91xxxxxxxxxx" email="" seq="1" tag="some clientside random data"/> </sms> </message> 

but using form works fine ,code form

echo "<form action=\"url\" method=\"post\" target=\"_blank\">";      echo "<input type=\"textarea\" id=\"txt\" name='data' style='width:600px' value='$xml1'></input>";     echo "<input type=\"submit\" name=\"action\" value=\"send\">";     echo "</form>"; 

when send data using form shows sent status when send using curl shows output :

    <?xml version="1.0" encoding="iso-8859-1"?>     <messageack>     <err code="65535" desc="the specified message not conform dtd"/> </messageack>  

thanks

how did set $xml1 variable?

make sure used $xml1 = file_get_contents($xmlfilepath) istead of simplexml_load_file($xmlfilepath)


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -