Welcome, Guest. Please login or register.

Author Topic: Posting XML data to aspx script using PHP  (Read 6466 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline mandm

  • Newbie
  • *
  • Join Date: Jul 2010
  • Posts: 2
    • Show all replies
Re: Posting XML data to aspx script using PHP
« on: July 10, 2010, 04:34:42 AM »
This code somehow does not work for me?...did it work for anyone?
 

Offline mandm

  • Newbie
  • *
  • Join Date: Jul 2010
  • Posts: 2
    • Show all replies
Re: Posting XML data to aspx script using PHP
« Reply #1 on: July 20, 2010, 03:34:30 PM »
So may be its me that i am doing something wrong or i do not understand the curl concepts yet, let me ask you in detail


$year
=date('Y');
$month=date('m');
$day=date('d');

$xml = file_get_contents("http://e-edition.metro.co.uk/$year/$month/$day/edition.xml");

This part is where the latest XML data is read by the php code into a variable

$ch = curl_init(); //initiate the curl session
curl_setopt($ch, CURLOPT_URL, "http://edition.pagesuite-professional.co.uk/create_pdf.aspx?");

///here you set the URL to post to so i have a similar aspx URL i should be putting that here?

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // tell curl to return data in a variable
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); // post the xml
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // set timeout in seconds
$xmlResponse = curl_exec ($ch);
curl_close ($ch);

$start=strpos($xmlResponse, "http");
$url=substr($xmlResponse, $start);
$end=strpos($url, ".pdf");
$url=substr($url, 0, $end+4);

This $xmlResponse is the response from the receiving server that it sends back to our code
and in the later code you just create a pdf file downloadable for this xml

echo
"Click here to download the Metro";
?>

so few questions that i have are, my XML is


     
       
          John Doe
         

     


is this the same format as the news paper XML, and can this be used to post using curl with all the same parameters?
secondly, how can i test the receiving script on my server? can you point me to a receiving post script?

All these answers will definetely help me a lot