Five9's API: How to pull reports using SOAP API and Basic Authentication

前端 未结 3 1992
旧巷少年郎
旧巷少年郎 2021-02-04 17:33

We are trying to access data from Five9\'s server using there reporting API. We have written code below but are not getting any results. To me it looks like issue is with the Au

3条回答
  •  感情败类
    2021-02-04 18:20

    I know this is an old question, but we recently switched to using Five9 and I couldn't find any PHP examples to work with. The following illustrates how to connect using standard credentials, and execute the call list. I've included the entire selection criteria structure (commented out) for your reference. If you include a selection property, you must specify the corresponding criteria.

    $soap = null;
    $wsdl = "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl";
    
    $user = "yourloginid";
    $pass = "yourpassword";
    
    $soap_options = array("login" => $user, "password" => $pass);
    
    $soap = new SoapClient($wsdl, $soap_options);
    
    /* create the callLogReportCriteria data selection structure */
    $arryParams['time']  = array("start" => "2013-05-05T00:00:01",
                                 "end" => "2013-05-05T09:00:00");
    $arryParams['criteria'] = array("callTypes" =>  array("INBOUND","OUTBOUND"));
    
    /************ Entire Structure for selection criteria *************/
    /*$arryParams['criteria'] = array("ANI" =>  "6178752803",
                                    "Agents" => "",
                                    "callTypes" =>  array("INBOUND","OUTBOUND"),
                                    "campaigns" =>  "",
                                    "dispositions" => "",
                                    "Lists" =>  "",
                                    "skillGroups" => ""
                                   );*/
    
    $result = $soap->getCallLogReport($arryParams);
    
    if(isset($result->return->records)) {
        /* you have records returned */
        $objRecords = $result->return->records;
    
        for($i=0 ; $i < sizeof($objRecords) ; $i++) {
            /* do your processing */
            printf("ANI: %s
    ", $objRecords[$i]->values->data[3]); //4th element has ANI } }

    Certain lines of code could be combined, but for the sake of understandability I broke them out. You will also want to utilize a try/catch around the actual SOAP call for error handling.

    Hopefully this will help shorten someone's learning curve. I know I would have loved to have had this a month ago!!

提交回复
热议问题