dfowler Posted April 30, 2008 Share Posted April 30, 2008 Hey guys, I'm trying to send information to an external screening site and I can't get it to work. I keep getting an error from them stating they are unable to parse the XML I am sending. I was hoping somebody could look at the code and tell me if I am leaving something out, or doing something wrong. Thanks for any help! $datax_info = '<?xml version="1.0" encoding="ISO-8859-1" ?>'; $datax_info .= "\n\t<DATAXINQUIRY>\n\t\t<AUTHENTICATION>\n\t\t\t<LICENSEKEY>".$key."</LICENSEKEY>\n"; $datax_info .= "\t\t\t<PASSWORD>".$password."</PASSWORD>\n\t\t</AUTHENTICATION>\n\t\t<QUERY>\n\t\t\t<TRACKID>".$trackid."</TRACKID>\n\t\t\t<TYPE>".$type."</TYPE>\n\t\t\t<DATA>"; $datax_info .= "\n\t\t\t\t<NAMEFIRST>".$name_first."</NAMEFIRST>\n\t\t\t\t<NAMELAST>".$name_last."</NAMELAST>\n\t\t\t\t<STREET1>".$address_1."</STREET1>\n\t\t\t\t<STREET2>".$address_2."</STREET2>"; $datax_info .= "\n\t\t\t\t<CITY>".$city."</CITY>\n\t\t\t\t<STATE>".$state."</STATE>\n\t\t\t\t<ZIP>".$zipcode."</ZIP>\n\t\t\t\t<PHONEHOME>".$phone_home."</PHONEHOME>\n\t\t\t\t<PHONECELL>".$phone_cell."</PHONECELL>"; $datax_info .= "\n\t\t\t\t<PHONEWORK>".$phone_work."</PHONEWORK>\n\t\t\t\t<PHONEEXT>".$emp_phone_ext."</PHONEEXT>\n\t\t\t\t<EMAIL>".$email_address."</EMAIL>\n\t\t\t\t<DOBYEAR>".$birth_year."</DOBYEAR>"; $datax_info .= "\n\t\t\t\t<DOBMONTH>".$birth_month."</DOBMONTH>\n\t\t\t\t<DOBDAY>".$birth_day."</DOBDAY>\n\t\t\t\t<SSN>".$dp_ssn."</SSN>\n\t\t\t\t<DRIVERLICENSENUMBER>".$DLNumber."</DRIVERLICENSENUMBER>"; $datax_info .= "\n\t\t\t\t<DRIVERLICENSESTATE>".$DLState."</DRIVERLICENSESTATE>\n\t\t\t\t<WORKNAME>".$employer."</WORKNAME>\n\t\t\t\t<BANKNAME>".$bank_name."</BANKNAME>\n\t\t\t\t<BANKACCTNUMBER>".$account_number."</BANKACCOUNT>"; $datax_info .= "\n\t\t\t\t<BANKABA>".$account_routing."</BANKABA>\n\t\t\t</DATA>\n\t\t</QUERY>\n\t</DATAXINQUIRY>\n"; $datax_ch = curl_init(); curl_setopt($datax_ch, CURLOPT_URL, 'https://rc.verihub.com/datax/'); curl_setopt($datax_ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($datax_ch, CURLOPT_POST, 1); curl_setopt($datax_ch, CURLOPT_POSTFIELDS, $datax_info); curl_setopt($datax_ch, CURLOPT_RETURNTRANSFER, 1); $datax_result = curl_exec($datax_ch); if (curl_errno($datax_ch)) { print curl_error($datax_ch); } curl_close($datax_ch); echo $datax_result; Link to comment https://forums.phpfreaks.com/topic/103559-xml-and-curl/ Share on other sites More sharing options...
rhodesa Posted April 30, 2008 Share Posted April 30, 2008 These tags don't match: <BANKACCTNUMBER>".$account_number."</BANKACCOUNT> Also, try adding this: (but it's most likely just the above problem) curl_setopt($datax_ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); Link to comment https://forums.phpfreaks.com/topic/103559-xml-and-curl/#findComment-530325 Share on other sites More sharing options...
rhodesa Posted April 30, 2008 Share Posted April 30, 2008 Also, it's a lot easier to use something like SimpleXML to build the XML. With the current method you don't escape HTML characters like > and <. SimpleXML will do that for you. Link to comment https://forums.phpfreaks.com/topic/103559-xml-and-curl/#findComment-530326 Share on other sites More sharing options...
dfowler Posted April 30, 2008 Author Share Posted April 30, 2008 These tags don't match: <BANKACCTNUMBER>".$account_number."</BANKACCOUNT> Also, try adding this: (but it's most likely just the above problem) curl_setopt($datax_ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); Wow, that is why it always helps to have another pair of eyes! <BANKACCOUNT>".$account_number."</BANKACCOUNT> Works perfectly now! Link to comment https://forums.phpfreaks.com/topic/103559-xml-and-curl/#findComment-530332 Share on other sites More sharing options...
rhodesa Posted April 30, 2008 Share Posted April 30, 2008 If you have a similar problem in the future, this is all I did to find the error: <?php $datax_info = '<?xml version="1.0" encoding="ISO-8859-1" ?>'; $datax_info .= "\n\t<DATAXINQUIRY>\n\t\t<AUTHENTICATION>\n\t\t\t<LICENSEKEY>".$key."</LICENSEKEY>\n"; $datax_info .= "\t\t\t<PASSWORD>".$password."</PASSWORD>\n\t\t</AUTHENTICATION>\n\t\t<QUERY>\n\t\t\t<TRACKID>".$trackid."</TRACKID>\n\t\t\t<TYPE>".$type."</TYPE>\n\t\t\t<DATA>"; $datax_info .= "\n\t\t\t\t<NAMEFIRST>".$name_first."</NAMEFIRST>\n\t\t\t\t<NAMELAST>".$name_last."</NAMELAST>\n\t\t\t\t<STREET1>".$address_1."</STREET1>\n\t\t\t\t<STREET2>".$address_2."</STREET2>"; $datax_info .= "\n\t\t\t\t<CITY>".$city."</CITY>\n\t\t\t\t<STATE>".$state."</STATE>\n\t\t\t\t<ZIP>".$zipcode."</ZIP>\n\t\t\t\t<PHONEHOME>".$phone_home."</PHONEHOME>\n\t\t\t\t<PHONECELL>".$phone_cell."</PHONECELL>"; $datax_info .= "\n\t\t\t\t<PHONEWORK>".$phone_work."</PHONEWORK>\n\t\t\t\t<PHONEEXT>".$emp_phone_ext."</PHONEEXT>\n\t\t\t\t<EMAIL>".$email_address."</EMAIL>\n\t\t\t\t<DOBYEAR>".$birth_year."</DOBYEAR>"; $datax_info .= "\n\t\t\t\t<DOBMONTH>".$birth_month."</DOBMONTH>\n\t\t\t\t<DOBDAY>".$birth_day."</DOBDAY>\n\t\t\t\t<SSN>".$dp_ssn."</SSN>\n\t\t\t\t<DRIVERLICENSENUMBER>".$DLNumber."</DRIVERLICENSENUMBER>"; $datax_info .= "\n\t\t\t\t<DRIVERLICENSESTATE>".$DLState."</DRIVERLICENSESTATE>\n\t\t\t\t<WORKNAME>".$employer."</WORKNAME>\n\t\t\t\t<BANKNAME>".$bank_name."</BANKNAME>\n\t\t\t\t<BANKACCTNUMBER>".$account_number."</BANKACCOUNT>"; $datax_info .= "\n\t\t\t\t<BANKABA>".$account_routing."</BANKABA>\n\t\t\t</DATA>\n\t\t</QUERY>\n\t</DATAXINQUIRY>\n"; header('Content-type:text/xml'); print $datax_info; ?> ...opened it in a browser and it showed me where the error was Link to comment https://forums.phpfreaks.com/topic/103559-xml-and-curl/#findComment-530337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.