Webservice using cURL and SOAP

Options
Hi,


I am currently trying to fetch donations from convio using webservice. I wonder if there is a sample code for Webservice using cURL and Soap with PHP? Looking at its documentation, there is only limited information - http://open.convio.com/webservices/#main.curl.html. Sorry, I'm new to cURL and Soap.




Thanks
Tagged:

Comments

  • Hello again!


    I didn't do anything with cURL, but have you looked at the console as a starting point? (Change the red to match your org.)


    https://webservices.cluster3.convio.net/1.0/ABC/console


    Or there is a pretty buried link in the admin UI...


    Setup > Site Options > Open API Configuration > Configure or View API Logs - Then look all the way to the bottom of the logs page for a link.


    So, login using one of your API Admin Accounts. Then on the Query tab, you can test a request and see the results.

    select ConsId from Constituent where username = 'brianpmucha'


    Then the console will show you the soap request and response.

    <?xml version='1.0' encoding='UTF-8' ?>

    <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'&gt;

    <soap:Header>

    <Session xmlns='urn:soap.convio.com'>

    <SessionId>1093417554ac21fb391861419d2954805bb36fd0:JSESSIONID=9B5B7EEBADF1D525C777892A658AFC3A.app311b:1173441:1730:2016-09-26T14:53:55.233Z</SessionId>

    </Session>

    </soap:Header>

    <soap:Body>

    <Query xmlns='urn:soap.convio.com'>

    <QueryString>select ConsId from Constituent where username = 'brianpmucha'</QueryString>

    <Page>1</Page>

    <PageSize>100</PageSize>

    </Query>

    </soap:Body>

    </soap:Envelope>


    <?xml version='1.0' encoding='UTF-8'?>

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

    <soap:Body>

    <QueryResponse xmlns="urn:soap.convio.com" xmlns:ens="urn:object.soap.convio.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <Record xsi:type="ens:Constituent">

    <ens:ConsId>1105632</ens:ConsId>

    </Record>

    </QueryResponse>

    </soap:Body>

    </soap:Envelope>



    .NET has a Web Services component that handles all this, so I didn't deal with soap at all in my projects either.


    There's an old PHP framework for the APIs that might be interesting to check out.


    Here's the old community thread:

    https://community.blackbaud.com/forums/viewtopic/100/12167?post_id=40452#p40452


    And the file:

    http://open.convio.com/downloads/php-library-for-convio-open.html


  • Something like this should work. Look at your wsdl to find the fields needed to make a query to get donations.


    <?php

    // Load the WSDL

    $client = new SoapClient('https://webservices.cluster3.convio.net/1.0/ABC/wsdl');


    // Log in to CWS

    $login = $client->Login(array('UserName'=>'YOUR_USERNAME', 'Password'=>'YOUR_PASSWORD'));


    // Set the session header

    $headerBody = array('SessionId'=>$login->Result->SessionId);

    $header = new SoapHeader('urn:soap.convio.com', 'Session', $headerBody);

    $client->__setSoapHeaders($header);


    $response = $client->Query(array('QueryString'=>"select * from Constituent where ConsName.FirstName = 'matthew' and ConsName.LastName = 'smith'", 'Page'=>1, 'PageSize'=>200));

    print_r($response);

    ?>

Categories