22855 Posts in 9971 Topics by 2805 members
|Go to End|
11 January 2012 at 8:45am
I've created a form that is a gateway to an online payment center that my employer uses to receive donations. The form is supposed to find out how the donor would like to pay, gather the necessary details, write those details to an XML file and then send the XML file to an external URL. So far, the form does the first three steps perfectly. I cannot get the file to send and if it is sending, I cannot get the response from their server to populate my getBody() function.
I've gone through many different steps and most recently I am getting the error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8388608 bytes) in C:\xampp\htdocs\pnwu\sapphire\core\control\HTTPRequest.php on line 33
Am I over-thinking this? Is there a simple way to just post this XML file to the URL? Any suggestions would be great. Also if you have successfully sent an XML file from SS, I'd love to know how you accomplished it.
11 January 2012 at 8:52am
Can't you just send the XML as a string instead of trying to save it to a file and sending that?
Other gateways I've worked with allowed the XML to be sent in such a fashion.
11 January 2012 at 10:48am
Do you mean as a part of the URL?
11 January 2012 at 11:05am
No I was rather thinkíng about using cURL to post the data to them if that's what they want.
If you're using cURL to do a post you're going to need some kind of key though.
Are you contacting them directly or are they contacting an URL on your server and expecting an XML response?
If the latter I would try just outputting the XML directly to the screen.
11 January 2012 at 11:40am
I am contacting them directly. Using cURL could be an option. Is it native in SS?
11 January 2012 at 12:02pm
No cURL is native to PHP if you're on a decent host. Looking through SS_HTTPRequest it seems that this class is only for parsing and working with the site URL for SilverStripe and not handling external URL:s. I think cURL might be your best option if that's the kind of thing you need to do.
If you need to send a file try this: http://dtbaker.com.au/random-bits/uploading-a-file-using-curl-in-php.html
12 January 2012 at 8:17am
I have tried the cURL approach and I don't get any errors but I'm not being redirected to the URL I'm giving it. That is the endgame in this scenario. To be sent with my XML file (or string) to the destination URL.
12 January 2012 at 9:00am
Ok so there's supposed to be a redirect after sending the file and not a separate request from their server to the URL you specify?
Could you maybe link the specs so I could read them?
You can try setting
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
And cURL should follow any redirects and return the results from them. Dump the $response variable to find out what kind of response you're getting.
|Go to Top|