Method Community

 

MethodAPISelect_XMLV2 returns non-array for multiple results

Last post 11-19-2013 8:56 AM by furrywombat. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-19-2013 8:06 AM

    MethodAPISelect_XMLV2 returns non-array for multiple results

    API call is returning a string, when it should be returning an array. Look:

    object(stdClass)#2 (1) {
    ["MethodAPISelect_XMLV2Result"]=>
    string(377) "

    ACME, INC
    1060


    OTHER, INC
    1742

    "
    }

    Here's the code:

    $soap = new SoapClient("https://www.methodintegration.com/MethodAPI/service.asmx?WSDL");

    $result = $soap->MethodAPISelect_XMLV2(array(

    "strCompanyAccount" => "foobar",
    "strLogin" => "foobar",
    "strPassword" => "foobar",
    "strSessionID" => "",
    "strTable" => "Customer",
    "strFields" => "CompanyName,RecordID",
    "strWhereClause" => "Email = 'email@address.com'"

    ));

    echo "<code><pre>";

    var_dump($result);

    echo "</pre></code>";

    Why am I not getting an array? I cannot work with a string like this.

  • 11-19-2013 8:46 AM In reply to

    Re: MethodAPISelect_XMLV2 returns non-array for multiple results


    Hi furrywombat,

    MethodAPISelect_XMLV2 does not return a string array. It returns a string of xml. Look closer at the raw response you should see something like

    <?xml version="1.0" encoding="windows-1252" ?><MethodAPI response = "Success" MaxRecords= "False"><MethodIntegration Table='Customer'><CompanyName>MyCompany</CompanyName> <RecordID>64</RecordID> </Record> <Record> <CompanyName>MyOtherCompany</CompanyName> <RecordID>66</RecordID> </Record></MethodIntegration></MethodAPI>

    Dave

  • 11-19-2013 8:56 AM In reply to

    Re: MethodAPISelect_XMLV2 returns non-array for multiple results

    David,

    Thanks for pointing out the obvious! You would not believe how much time I spent tearing my hair out over this. How embarrassing :) Greatly appreciated.

    Best,

    Charles

Page 1 of 1 (3 items)