Creating Funds Remotely with php

30 views
Skip to first unread message

Coder

unread,
Jun 16, 2011, 10:55:31 PM6/16/11
to Donor Tools API
Ryan sent me the xml you need to create a fund and web page over the
Internet on Donor Tools.

In the past, I have adopted curl from the example code from Andrew
Buzzell from another post and it's been a big help.

Here is the link
https://github.com/mysmallidea/Donor-Tools-PHP-Helper/blob/8fb3f1eee602df3f049f3273cc2bd55b96d47177/donortools.php

Before, I was always getting xml files from Donor Tools and reading
them. This time, I needed to send an xml file to create the fund and
the web page on Donor Tools.

I ran into a problem in code adapted from the function
get_xml_from_api. Specifically these lines:

if ($post_xml)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "XML=$post_xml");
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/
xml"));
}

Running as is I was rewarded with a 500 error from the server. Not
cool. And it doesn't matter if you use application/xml or text/xml.
(Still doesn't matter even when you get it working.)

To make a long story short the fix was to get rid of the XML= in the
second curl option. Change:

curl_setopt($ch, CURLOPT_POSTFIELDS, "XML=$post_xml");
to
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_xml);

and it works. And I tried every variation I could think of first.
xml=, &xml=, &XML= all come to mind.

Now the code example above is syntactically correct. It's almost as if
this is something different happening here than the usual URL type
POST. Is this some sort of Rubyism maybe?

There were other issues but this was the big one.

Ryan Heneise

unread,
Jun 17, 2011, 5:25:46 PM6/17/11
to Donor Tools API
Thanks for sharing this! To tell you the truth, I'm not entirely sure
why the Funds API would be different. I'll take a look and see if
there's anything I can correct. I'm glad you were able to get it
working though.

Cheers,
Ryan

On Jun 16, 9:55 pm, Coder <s.dro...@gmail.com> wrote:
> Ryan sent me the xml you need to create a fund and web page over the
> Internet on Donor Tools.
>
> In the past, I have adopted curl from the example code from Andrew
> Buzzell from another post and it's been a big help.
>
> Here is the linkhttps://github.com/mysmallidea/Donor-Tools-PHP-Helper/blob/8fb3f1eee6...
Reply all
Reply to author
Forward
0 new messages