abanksob1 Posted October 11, 2010 Report Posted October 11, 2010 hi post an XML file or Data to https:// URl I have an xml filled out form, that needs to be sent to a url how do i go about this please help <? include_once "connect.php"; include_once "../functions.php"; if (!$compid) { header("Location: login.php"); exit("Not logged in"); } $ids = array(); $rs = mysql_query("SELECT id FROM leads WHERE origQuotes>$minOrigQuotes AND origQuotes>fetchedQuotes") or die(mysql_error()); while (list($id) = mysql_fetch_array($rs)) { if (!empty($_REQUEST["cb$id"])) { $ids[] = $id; } } if (count($ids)) { $ids = "(id=".implode(" OR id=", $ids).")"; $rs = mysql_query("SELECT leftLeads FROM companies WHERE id=$compid") or die(mysql_error()); list($limit) = mysql_fetch_array($rs); } else $limit=$ids=0; include "header.php"; $rs = mysql_query("SELECT email FROM companies WHERE id=$compid") or die(mysql_error()); list($compEmail) = mysql_fetch_array($rs); $rs = mysql_query("SELECT * FROM leads WHERE $ids LIMIT $limit"); $ok=0; $xml = intval($_REQUEST['xml']); $xmlMSG = ""; $ids = array(); $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: Movers Community <info@moverscommunity.com>\n"; while ($row = mysql_fetch_row($rs)) { for ($x = 0; $x < mysql_num_fields($rs); $x++) { $a=mysql_fetch_field($rs, $x); ${$a->name} = trim(stripslashes($row[$x])); } if ($xml == 0) { $MSG = "Name = $firstName $lastName<br>"; $MSG .= "Home Phone = $homePhone<br>"; $MSG .= "Work Phone = $workPhone<br>"; $MSG .= "Email = $email<br>"; $MSG .= "Move Date = ".date("m/d/Y", $Move_Date)."<br>"; $MSG .= "Move Size = $Move_Size<br>"; $MSG .= "From City = $From_City<br>"; $MSG .= "From State = $From_State<br>"; $MSG .= "From Zip = $From_Zip<br>"; $MSG .= "To City = $To_City<br>"; $MSG .= "To State = $To_State<br>"; $MSG .= "To Zip = $To_Zip<br>"; $MSG .= "Comments = ".nl2br($comment)."<br>"; $MSG = "<div>$MSG</div>"; $subject = "Lead From Movers Community"; $st = mail($compEmail, $subject, $MSG, $headers); echo ($st) ? "Lead #$id sent.<br>" : "Lead #$id couldn't be sent.<br>"; flush(); if ($st) { $ok++; mysql_query("UPDATE companies SET leftLeads=leftLeads-1, totalLeadsUsed=totalLeadsUsed+1 WHERE id=$compid") or die(mysql_error()); mysql_query("UPDATE leads SET fetchedQuotes=fetchedQuotes+1 WHERE id='$id'") or die("ERROR #1322"); mysql_query("REPLACE INTO chosenLeads (lid, cid) VALUES('$id','$compid')") or die("ERROR #1323"); } } else { $xmlMSG .= " <lead>\n"; $xmlMSG .= " <Name>$firstName $lastName</Name>\n"; $xmlMSG .= " <Home_Phone>$homePhone</Home_Phone>\n"; $xmlMSG .= " <Work_Phone>$workPhone</Work_Phone>\n"; $xmlMSG .= " <Email>$email</Email>\n"; $xmlMSG .= " <Move_Date>".date("m/d/Y", $Move_Date)."</Move_Date>\n"; $xmlMSG .= " <Move_Size>$Move_Size</Move_Size>\n"; $xmlMSG .= " <From_City>$From_City</From_City>\n"; $xmlMSG .= " <From_State>$From_State</From_State>\n"; $xmlMSG .= " <From_Zip>$From_Zip</From_Zip>\n"; $xmlMSG .= " <To_City>$To_City</To_City>\n"; $xmlMSG .= " <To_State>$To_State</To_State>\n"; $xmlMSG .= " <To_Zip>$To_Zip</To_Zip>\n"; $xmlMSG .= " <Comments><![CDATA[$comment]]</Comments>\n"; $xmlMSG .= " </lead>\n"; $ids[] = $id; } //echo "$MSG<BR><BR><BR>"; //die($MSG); //header('location: thanks.php'); //exit(); } if ($xml && count($ids)) { $xmlMSG = "<leads>\n$xmlMSG</leads>"; //print_r($ids); //die($xmlMSG); $subject = "Leads From Movers Community"; $st = mail($compEmail, $subject, $xmlMSG, $headers); if ($st) { foreach ($ids as $id) { echo "Lead #$id sent.<br>"; $ok++; mysql_query("UPDATE companies SET leftLeads=leftLeads-1, totalLeadsUsed=totalLeadsUsed+1 WHERE id=$compid") or die(mysql_error()); mysql_query("UPDATE leads SET fetchedQuotes=fetchedQuotes+1 WHERE id='$id'") or die("ERROR #1322"); mysql_query("REPLACE INTO chosenLeads (lid, cid) VALUES('$id','$compid')") or die("ERROR #1323"); } } echo "Leads couldn't be sent.<br>"; } echo "<br><br><center><big><b>"; echo "<span style='color:red'>$ok</span> leads were sent to $compEmail<br>"; echo "</b></big></center>"; include "footer.php"; ?> please let me Quote
falkencreative Posted October 11, 2010 Report Posted October 11, 2010 Perhaps you can explain what you are trying to do a bit better? I'm not sure what you mean. You could add data to a database... or email it to someone... but I'm not sure what you mean by "send it to a URL." Quote
BeeDev Posted October 12, 2010 Report Posted October 12, 2010 I guess he means sending the XML string as a POST or GET data to a specific URL. You need to use xmlHttpObject in Javascript, or use cURL in PHP but I think you need to have cURL extension installed, which depends on your hosting. Just search for above terms on google and you should get your answers in detail. Quote
abanksob1 Posted October 15, 2010 Author Report Posted October 15, 2010 well basically after i collect the data i need to send it to a url data system currently i can send the file as a xml and html to people email addresses , i need to be able to send it for example http://test.granot.com/bin/wc.dll?lidgw~TESTLEADPOSTING they have a system where automatically collect the data as xml . usually me webmaster deals with this he is currently on vacation is this a hard thing to do ? Quote
BeeDev Posted October 15, 2010 Report Posted October 15, 2010 (edited) As I said, You need to use xmlHttpRequest object in Javascript, or cURL in PHP to achieve that. And no it's not that hard, just Google cURL or xmlHttpRequest, and read up. Taken from php.net (http://php.net/manual/en/book.curl.php): <?php $data = "<soap:Envelope>[...]</soap:Envelope>"; $tuCurl = curl_init(); curl_setopt($tuCurl, CURLOPT_URL, "https://example.com/path/for/soap/url/"); curl_setopt($tuCurl, CURLOPT_PORT , 443); curl_setopt($tuCurl, CURLOPT_VERBOSE, 0); curl_setopt($tuCurl, CURLOPT_HEADER, 0); curl_setopt($tuCurl, CURLOPT_SSLVERSION, 3); curl_setopt($tuCurl, CURLOPT_SSLCERT, getcwd() . "/client.pem"); curl_setopt($tuCurl, CURLOPT_SSLKEY, getcwd() . "/keyout.pem"); curl_setopt($tuCurl, CURLOPT_CAINFO, getcwd() . "/ca.pem"); curl_setopt($tuCurl, CURLOPT_POST, 1); curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $data); curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"", "Content-length: ".strlen($data))); $tuData = curl_exec($tuCurl); if(!curl_errno($tuCurl)){ $info = curl_getinfo($tuCurl); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; } else { echo 'Curl error: ' . curl_error($tuCurl); } curl_close($tuCurl); echo $tuData; ?> Edited October 15, 2010 by BeeDev Quote
Ashley Stern Posted October 28, 2010 Report Posted October 28, 2010 As I said, You need to use xmlHttpRequest object in Javascript, or cURL in PHP to achieve that. And no it's not that hard, just Google cURL or xmlHttpRequest, and read up. Taken from php.net (http://php.net/manual/en/book.curl.php): <?php $data = "<soap:Envelope>[...]</soap:Envelope>"; $tuCurl = curl_init(); curl_setopt($tuCurl, CURLOPT_URL, "https://example.com/path/for/soap/url/"); curl_setopt($tuCurl, CURLOPT_PORT , 443); curl_setopt($tuCurl, CURLOPT_VERBOSE, 0); curl_setopt($tuCurl, CURLOPT_HEADER, 0); curl_setopt($tuCurl, CURLOPT_SSLVERSION, 3); curl_setopt($tuCurl, CURLOPT_SSLCERT, getcwd() . "/client.pem"); curl_setopt($tuCurl, CURLOPT_SSLKEY, getcwd() . "/keyout.pem"); curl_setopt($tuCurl, CURLOPT_CAINFO, getcwd() . "/ca.pem"); curl_setopt($tuCurl, CURLOPT_POST, 1); curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $data); curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"", "Content-length: ".strlen($data))); $tuData = curl_exec($tuCurl); if(!curl_errno($tuCurl)){ $info = curl_getinfo($tuCurl); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; } else { echo 'Curl error: ' . curl_error($tuCurl); } curl_close($tuCurl); echo $tuData; ?> I think he finds the js object easier than the curl concept. Quote
AchakKeise Posted November 19, 2011 Report Posted November 19, 2011 (edited) I am trying to send an XML file to another localhost:1078/XML/Test.aspx using http web request. I need help for that. Edited November 19, 2011 by Andrea Link Deleted - No SPAM, please Quote
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.
Note: Your post will require moderator approval before it will be visible.