How do I Upload XML file using cUrl?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ave,

I have a client who used Lead360.Com to manage their Leads. We have a Leads Management application in place that creates an XML file of the lead which give the client manually to download.

What are client is requesting is to POST the XML File directly to their Leads360.Com account. We have a POST Url from Leads360 where we can send the lead, but I'm not sure what kind of a cUrl script I need to use to POST an XML file. I've handled POST Data before using cUrl but I haven't written a cUrl script that uploads a file to a URL.

From what I have gathered so far ... this is what I have ...

[CODE]

$filename = "file.xml";
$handle = fopen($filename, "r");
$XPost = fread($handle, filesize($filename));
fclose($handle);

$url = "https://secure.leads360.com/Import.aspx";;
$ch = curl_init(); // initialize curl handle

curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post to
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);

$result = curl_exec($ch); // run the whole process

[END CODE]

Am I on the right track here or am I missing something?

Thanks Guys!

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email]	sleepwalker@xxxxxxxxxxxxxxxx
[Web]	http://www.rahulsjohari.com





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux