cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Sending xml files using curl and php

From: Stephen Pynenburg <spynenburg_at_gmail.com>
Date: Thu, 16 Apr 2009 07:39:35 -0400

Assuming that processxml.php is receiving some data, the fault is very
likely in the URL as it contains ampersands (&). Since you're just
concatenating the data straight to 'data=', then processxml.php is probably
receving multiple useless arguments. Try calling urlencode on the URL (also
make sure you've changed the &amp; in in to simply &, and then urldecode it
in your processing page.
-Stephen

On Wed, Apr 15, 2009 at 16:40, Manish Katiyar <mkatiyar_at_gmail.com> wrote:

> On Thu, Apr 16, 2009 at 2:09 AM, <boris317_at_gmail.com> wrote:
> > You have a typo in your code. In the set opt post fields line :
> $postFileds
>
> I pasted the wrong version of the file. But even after correcting this
> typo it is not working.
>
> Thanks -
>
>
>
> > Sent from my Verizon Wireless BlackBerry
> >
> > -----Original Message-----
> > From: Manish Katiyar <mkatiyar_at_gmail.com>
> >
> > Date: Thu, 16 Apr 2009 01:18:05
> > To: <curl-and-php_at_cool.haxx.se>
> > Subject: Sending xml files using curl and php
> >
> >
> > Hi,
> >
> > I am a newbie and trying to send an xml file to another php file using
> > php and curl. I have my xml data in the format below in a file called
> > temp.xml
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <report>
> > <Mail>
> > <Subject>How are you ?</Subject>
> > <sender_name>user_at_domain.com</sender_name>
> > <Link>http://someurl.php?rit=1&amp;i=2231608&amp;k=9ac69b4f</Link>
> > </Mail>
> > <Mail>
> > ........................
> > </Mail>
> > </report>
> >
> >
> > And I am using the below php file to post xml data.
> >
> >
> > <?php
> > $xmldatafile="temp.xml";
> > function postData($postFields,$url){
> > $ch = curl_init();
> > curl_setopt($ch, CURLOPT_URL, $url);
> > curl_setopt($ch, CURLOPT_POST ,1);
> > curl_setopt($ch, CURLOPT_POSTFIELDS ,$postFileds);
> > curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
> > curl_setopt($ch, CURLOPT_HEADER ,0);
> > curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
> > $data = curl_exec($ch);
> > curl_close($ch);
> > return $data;
> > }
> >
> > $xmlData = file_get_contents($xmldatafile);
> > #echo $xmlData;
> > #$postFileds = 'data='. urlencode($xmlData);
> > $postFileds = 'data='.$xmlData;
> >
> > //call function
> > $result=postData($postFields,"http://localhost/processxml.php");
> > ?>
> >
> >
> > But for some reason it is not working. The processxml.php is not able
> > to retrieve the data. I guess this is due to the URL in the xml tag.
> > Do I need to treat is specially ? I have already removed special
> > characters from it before putting it into the xml file.
> >
> > Any help/pointers appreciated.
> >
> > -Thanks
> > _______________________________________________
> > http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> > _______________________________________________
> > http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> >
>
>
>
> --
> Thanks -
> Manish
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-04-16