API call switching webform2 to webform3

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

API call switching webform2 to webform3

Postby uselessinfoguru » Fri Dec 15, 2017 10:03 am

Strange I know, that's why I'm posting :P
Scenario:
We have inbound calls coming from postcards that were sent out.
When the call comes in, the reps hit webform(1) and that opens a search php file here
Code: Select all
<head>
    <title>Search</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
    <form action="searchmail.php" method="GET">
        <input type="text" name="query" />
        <input type="hidden" name="user" value=<?php echo $_GET['user'] ?> />
        <input type="submit" value="Search" />
    </form>
</body>
</html>

that's a simple search box which uses the postcard claim number for the search, which bring the reps to this
Code: Select all
<?php
$servername="localhost";
    $username="cron";
    $password="1234";
    $dbname="asterisk";

$user = $_GET['user'];

$conn=new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_error) {
       die("Connection failed:  " . $conn->connect_error);
    }
$query1 = "SELECT * from vicidial_closer_log where user = '$user' and status = 'INCALL';";

 $result=$conn->query($query1);
/* This will loop through all the rows until it reaches the end */
while ($row = $result->fetch_assoc()) {
if ($row['user'] == ($user)) $phone_number['phone_number'] = $row['phone_number'];
}

$search1 = array();

$ch = fopen("MU_06.23_mail data.csv", "r");
$header_row = fgetcsv($ch);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch1 = fopen("MU_08.18_mail data.csv", "r");
$header_row = fgetcsv($ch1);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch1)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch2 = fopen("MU_08.25_mail data.csv", "r");
$header_row = fgetcsv($ch2);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch2)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch3 = fopen("MU_09.01_mail data.csv", "r");
$header_row = fgetcsv($ch3);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch3)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch4 = fopen("MU_09.08_mail data.csv", "r");
$header_row = fgetcsv($ch4);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch4)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}

$ch5 = fopen("MU_09.15_mail data.csv", "r");
$header_row = fgetcsv($ch5);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch5)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}

$ch6 = fopen("MU_10.20_mail data.csv", "r");
$header_row = fgetcsv($ch6);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch6)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch7 = fopen("MU_10.27_mail data.csv", "r");
$header_row = fgetcsv($ch7);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch7)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch8 = fopen("MU_11.03_mail data.csv", "r");
$header_row = fgetcsv($ch8);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch8)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch9 = fopen("MU_11.10_mail data.csv", "r");
$header_row = fgetcsv($ch9);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch9)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}

$ch10 = fopen("MU_11.24_mail data.csv", "r");
$header_row = fgetcsv($ch10);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch10)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}

$ch11 = fopen("MU_12.01_mail data.csv", "r");
$header_row = fgetcsv($ch11);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch11)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$ch12 = fopen("MU_12.08_mail data.csv", "r");
$header_row = fgetcsv($ch12);

/* This will loop through all the rows until it reaches the end */
while($row = fgetcsv($ch12)) {
    if (in_array($_GET['query'], $row)) {
        echo '<div>' . implode(' | ', $row) . ' </div>';
       $search1[] = array_combine ($header_row, $row);
       $query = $_GET['query'];
       $file = fopen('mail.txt', "a");
       $file1 = fopen('mailwnumbers.txt', "a");
           fwrite($file, $query."\n");
           fwrite($file1, "" . $query . ", " . $phone_number['phone_number'] . "\n");
           fclose($fd);

    }
}
$first_name = $search1[0]['FIRST NAME'];
$last_name= $search1[0]['LAST NAME'];
$address1= $search1[0]['PRIMARY ADDRESS'];
$city= $search1[0]['CITY'];
$state= $search1[0]['ST'];
$postal_code = $search1[0]['ZIP'];
$gender = $search1[0]['GENDER'];
$middle_initial = $search1[0]['MI'];
$claim_number = $search1[0]['FINDER NUM'];
?>

<a href='http://SERVERIP/agc/api.php?source=test&user=6666&pass=VICIPASS&function=update_fields&agent_user=<?php echo $user; ?>&first_name=<?php echo $first_name; ?>&last_name=<?php echo $last_name; ?>&address1=<?php echo $address1; ?>&city=<?php echo $city; ?>&state=<?php echo $state; ?>&postal_code=<?php echo $postal_code; ?>&gender=<?php echo $gender; ?>&middle_initial=<?php echo $middle_initial; ?>&address3=<?php echo $claim_number; ?>' id="vicipop"><div><font size=5>Auto-Populate Vicidial Screen</font></div></a>



now... the <a href api link does what it's suppose to do, it auto populates all the information into the correct fields in vici, but when the rep hits the link, webform2 changes to webform3 and doesn't work right... any idea what could be causing this?
VERSION: 2.14-736a | BUILD: 200204-2336| Cluster Setup
uselessinfoguru
 
Posts: 74
Joined: Tue Jul 25, 2017 10:27 pm

Re: API call switching webform2 to webform3

Postby uselessinfoguru » Wed Dec 20, 2017 9:45 am

Hate to bump my own post, but I'm still now sure why this is happening? Anyone have any clues?
VERSION: 2.14-736a | BUILD: 200204-2336| Cluster Setup
uselessinfoguru
 
Posts: 74
Joined: Tue Jul 25, 2017 10:27 pm

Re: API call switching webform2 to webform3

Postby blackbird2306 » Wed Dec 20, 2017 10:18 am

Please post exactly what's in your webform1, webform2 and webform3 fields in campaign settings.
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: API call switching webform2 to webform3

Postby uselessinfoguru » Wed Dec 20, 2017 10:42 am

Code: Select all
webform:
   http://SERVERIP/agc/form/mailindex.php?user=--A--agent_log_id--B--

webform2:
   http://SERVERIP/agc/form/bincheck.php?date=--A--SQLdate--B--&list_id=--A--list_id--B-- &lead_id=--A--lead_id--B-- &recording_filename=--A--recording_filename--B-- &agent_name=--A--fullname--B-- &user=--A--user--B-- &firstname=--A--first_name--B-- &lastname=--A--last_name--B-- &phone=--A--phone_number--B-- &street=--A--address1--B-- &city=--A--city--B-- &state=--A--state--B-- &zip=--A--postal_code--B-- &email=--A--email--B--&ccexp=--A--vendor_lead_code--B--&ccnum=--A--province--B--&claim=--A--address3--B--&cccvv=--A--security_phrase--B--&altphone=--A--alt_phone--B--&dob=--A--address2--B--&gender=--A--gender--B--&user_group=--A--user_group--B--&source=--A--did_description--B--

webform3:
   http://SERVERIP/agc/form/bincheck.php?date=--A--SQLdate--B--&list_id=--A--list_id--B-- &lead_id=--A--lead_id--B-- &recording_filename=--A--recording_filename--B-- &agent_name=--A--fullname--B-- &user=--A--user--B-- &firstname=--A--first_name--B-- &lastname=--A--last_name--B-- &phone=--A--phone_number--B-- &street=--A--address1--B-- &city=--A--city--B-- &state=--A--state--B-- &zip=--A--postal_code--B-- &email=--A--email--B--&ccexp=--A--vendor_lead_code--B--&ccnum=--A--province--B--&claim=--A--address3--B--&cccvv=--A--security_phrase--B--&altphone=--A--alt_phone--B--&dob=--A--address2--B--&gender=--A--gender--B--&user_group=--A--user_group--B--&source=--A--did_description--B--


webform 2 and 3 are the same, because the api call messes up webform2, it turns into webform3, but then even that link doesn't work properly (i'm guessing the fields aren't populating correctly in that case) so the reps can hit the bottom webform3 to at least get a working link.
VERSION: 2.14-736a | BUILD: 200204-2336| Cluster Setup
uselessinfoguru
 
Posts: 74
Joined: Tue Jul 25, 2017 10:27 pm

Re: API call switching webform2 to webform3

Postby blackbird2306 » Wed Dec 20, 2017 5:33 pm

Please put in front of all webform links "VAR" and delete the whitespaces in your line like this:
Webform:
Code: Select all
VARhttp://SERVERIP/agc/form/mailindex.php?user=--A--agent_log_id--B--

Webform2:
Code: Select all
VARhttp://SERVERIP/agc/form/bincheck.php?date=--A--SQLdate--B--&list_id=--A--list_id--B--&lead_id=--A--lead_id--B--&recording_filename=--A--recording_filename--B--&agent_name=--A--fullname--B--&user=--A--user--B--&firstname=--A--first_name--B--&lastname=--A--last_name--B--&phone=--A--phone_number--B--&street=--A--address1--B--&city=--A--city--B--&state=--A--state--B--&zip=--A--postal_code--B--&email=--A--email--B--&ccexp=--A--vendor_lead_code--B--&ccnum=--A--province--B--&claim=--A--address3--B--&cccvv=--A--security_phrase--B--&altphone=--A--alt_phone--B--&dob=--A--address2--B--&gender=--A--gender--B--&user_group=--A--user_group--B--&source=--A--did_description--B--

Webform3 same with VAR prefix.

There are about 10-11 times whitespaces you should delete. E.g. "--B-- &"
Code: Select all
&list_id=--A--list_id--B-- &lead_id=

What means webform2 turns into webform3 ? Do you see webform1 button and below webform3 and again webform3 or is webform2 only missing then?
Are there any browser errors in web console (developer tools)?
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: API call switching webform2 to webform3

Postby uselessinfoguru » Thu Dec 21, 2017 1:09 pm

no errors, and yes, after api call the agent screen show webform, webform3, webform3... but the upper webform3 button doesn't work properly when this happens
VERSION: 2.14-736a | BUILD: 200204-2336| Cluster Setup
uselessinfoguru
 
Posts: 74
Joined: Tue Jul 25, 2017 10:27 pm

Re: API call switching webform2 to webform3

Postby uselessinfoguru » Fri Dec 29, 2017 9:48 am

took out the spacing, made no difference
VERSION: 2.14-736a | BUILD: 200204-2336| Cluster Setup
uselessinfoguru
 
Posts: 74
Joined: Tue Jul 25, 2017 10:27 pm

Re: API call switching webform2 to webform3

Postby blackbird2306 » Sat Jan 06, 2018 11:31 am

The reason for your problem seems to be the result of charset and urlencoding conflicts. In your "searchmail.php" there are various text files, which will be opened and written to without considering the source charset at all. In addition to this comes the lack of correctly urlencoding the "href api link". So I think your link will corrupt the vicidial api process somehow.
Make changes to searchmail.php at the end of file (about line 248):

Code: Select all
$first_name = $search1[0]['FIRST NAME'];
$last_name= $search1[0]['LAST NAME'];
$address1= $search1[0]['PRIMARY ADDRESS'];
$city= $search1[0]['CITY'];
$state= $search1[0]['ST'];
$postal_code = $search1[0]['ZIP'];
$gender = $search1[0]['GENDER'];
$middle_initial = $search1[0]['MI'];
$claim_number = $search1[0]['FINDER NUM'];

$encoding['first_name'] =  mb_detect_encoding($first_name);
$encoding['last_name'] =  mb_detect_encoding($last_name);
$encoding['address1'] =  mb_detect_encoding($address1);
$encoding['city'] =  mb_detect_encoding($city);
$encoding['state'] =  mb_detect_encoding($state);
$encoding['postal_code'] =  mb_detect_encoding($postal_code);
$encoding['gender'] =  mb_detect_encoding($gender);
$encoding['middle_initial'] =  mb_detect_encoding($middle_initial);
$encoding['claim_number'] =  mb_detect_encoding($claim_number);
print_r($encoding);

$first_name = rawurlencode(iconv('iso-8859-1','utf-8', $first_name));
$last_name = rawurlencode(iconv('iso-8859-1','utf-8', $last_name));
$address1 = rawurlencode(iconv('iso-8859-1','utf-8', $address1));
$city = rawurlencode(iconv('iso-8859-1','utf-8', $city));
$state = rawurlencode(iconv('iso-8859-1','utf-8', $state));
$postal_code = rawurlencode(iconv('iso-8859-1','utf-8', $postal_code));
$gender = rawurlencode(iconv('iso-8859-1','utf-8', $gender));
$middle_initial = rawurlencode(iconv('iso-8859-1','utf-8', $middle_initial));
$claim_number = rawurlencode(iconv('iso-8859-1','utf-8', $claim_number));
?>

<a href='http://SERVERIP/agc/api.php?source=test&user=6666&pass=VICIPASS&function=update_fields&agent_user=<?php echo $user; ?>&first_name=<?php echo $first_name; ?>&last_name=<?php echo $last_name; ?>&address1=<?php echo $address1; ?>&city=<?php echo $city; ?>&state=<?php echo $state; ?>&postal_code=<?php echo $postal_code; ?>&gender=<?php echo $gender; ?>&middle_initial=<?php echo $middle_initial; ?>&address3=<?php echo $claim_number; ?>' id="vicipop"><div><font size=5>Auto-Populate Vicidial Screen</font></div></a>

Please post us output of print_r($encoding) and then change the part with iconv "iso-8859-1" with the right source charset.
Further post an example of your url link with real values, when this happens!
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 85 guests