Page 1 of 2
CCIVR - callcom php
Posted: 02 Jun 2016 03:03
by letacla
Hello,
I try to use a callcom, to call a php script to query a text file in which to return my OK or NO. in IE everything works as I expected, but when using callcom does not get the same result. does anyone know why not work? thank you.
Php script
<?php
$phone = $_GET['phone'];
$file = file_get_contents('Phone_test.txt');
if(strpos($file, "$phone") !== false)
{
echo "OK";
}else{
echo "NOK";
}
?>
file (Phone_test.txt)
012345678
098765432
111111111
222222222
Query test with phone=012345678 – result OK
Capture0.JPG
Query test with phone=012345677 – result NO
Capture01.JPG
CCIVR with $phone=012345678
Capture1.JPG
Re: CCIVR - callcom php
Posted: 03 Jun 2016 07:15
by sadim
Hi,
From what i can see the php script that you post is not the one that was tested.
On the screen shots the result is OK and NO, but on the script you have OK and NOK.
Re: CCIVR - callcom php
Posted: 03 Jun 2016 08:42
by letacla
Hi,
my mistake, the correct script has echo "NO".
br
Re: CCIVR - callcom php
Posted: 03 Jun 2016 09:43
by sadim
Case there is a error on file_get_contents(), your script returns NO.
I propose you to change your script to:
$phone = $_GET['phone'];
$file = file_get_contents('Phone_test.txt');
if ($file == false)
{
echo "OpenErr"
}
else {
if(strpos($file, "$phone") !== false)
{
echo "OK";
}else{
echo "NOK";
}
}
Re: CCIVR - callcom php
Posted: 03 Jun 2016 10:21
by letacla
I tested but I have the same results.
Capture2.jpg
.
I want to mention that I use the same method (PHP) to check whether a server responds to the command "ping" with the script below and I have no problems with it.
$ping_server = exec("ping -n 1 -w 20 192.168.1.11", $output, $retval);
if ($retval != 0) {
echo "NOK";
}
else
{
echo "OK"; }
thank you for your answer.
Re: CCIVR - callcom php
Posted: 03 Jun 2016 11:16
by sadim
Can you make the test, but instead of using phone number to search 012345678, using 098765432
Re: CCIVR - callcom php
Posted: 03 Jun 2016 13:13
by sadim
Hi,
If it works, then it is because of test strpos () != false, and i advise you check the link
http://php.net/manual/en/function.strpos.php
If does not work, then I am sorry but as I have no CCIvr, I do not see how I can help you further.
As strpos may return either FALSE (substring absent) or 0 (substring at start of string), strict versus loose equivalency operators must be used very carefully.
To know that a substring is absent, you must use:
=== FALSE
To know that a substring is present (in any position including 0), you can use either of:
!== FALSE (recommended)
> -1 (note: or greater than any negative number)
To know that a substring is at the start of the string, you must use:
=== 0
To know that a substring is in any position other than the start, you can use any of:
> 0 (recommended)
!= 0 (note: but not !== 0 which also equates to FALSE)
!= FALSE (disrecommended as highly confusing)
Regards
Re: CCIVR - callcom php
Posted: 03 Jun 2016 14:43
by cavagnaro
Maybe in the return try to get also the function value
Enviado de meu E6633 usando Tapatalk
Re: CCIVR - callcom php
Posted: 03 Jun 2016 16:50
by sadim
Hi Cavagnaro,
Although it should be done (programming good practice), if you check my second post, it has been done and the test result shows that that is not the cause of the problem.
Re: CCIVR - callcom php
Posted: 03 Jun 2016 18:22
by cavagnaro
What I mean is add the function itself in the output, something like echo "No". strpos($1, $2)
Enviado de meu E6633 usando Tapatalk