angelleye Posted June 13, 2007 Share Posted June 13, 2007 I'm trying to use CURL to submit XML requests to web service API's. I've got everything working except that I can't figure out how to actually attach my own custom XML string request to the POST. As such, I'm getting XML responses that simply say 'Invalid Request'. Here's what my CURL function currently looks like: function CURLRequest($xmlRequest) { $curl = curl_init(); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT, 120); curl_setopt($curl, CURLOPT_URL, $this -> EndPointURL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //execute the curl POST and then clean out the bad line in the response. $xmlResponse = curl_exec($curl); curl_close($curl); return $xmlResponse; } //End CURLRequest function What do I need to add to the CURL options in order to include the XML data with the POST? Any information would be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/55482-solved-how-to-attach-post-data-to-curl/ Share on other sites More sharing options...
mr_zhang Posted June 14, 2007 Share Posted June 14, 2007 You need the: curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $param); where $param is a string of 'var1=value1&var2=value2&var3=value3' Of course the variables are those required by the url you are trying to post. The value might be your xml file (or xml strings). Read CURL explanation from php.net to get examples. Quote Link to comment https://forums.phpfreaks.com/topic/55482-solved-how-to-attach-post-data-to-curl/#findComment-274330 Share on other sites More sharing options...
angelleye Posted June 14, 2007 Author Share Posted June 14, 2007 Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/55482-solved-how-to-attach-post-data-to-curl/#findComment-274368 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.