No output from php script.

Discussion in 'General' started by henkoegema, Aug 8, 2007.

  1. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    The following php script is suppose to give me the balance of Voipbuster, by dialing extension 3000

    Code:
    exten => 3000,1,Wait(1)
    exten => 3000,n,Playback(astcc-account-balance-is)
    exten => 3000,n,Set(status=${CURL(https://192.168.1.100:8888/credit/credit_voipbuster.php)})
    exten => 3000,n,NoOP(${status})
    exten => 3000,n,SayDigits(${status})
    exten => 3000,n,Playback(vm-goodbye)
    exten => 3000,n,Hangup()
    
    When I dial extension 3000, the ${status} remains empty.

    When I run
    https://192.168.1.100:8888/credit/credit_voipbuster.php
    directly in a web browser, it gives me the correct output. (8888 is the port number for the browser)

    This script worked correctly in Asterisk 1.4.14 with SuSE10.2, but I can't get it working in Elastix. Evenso I just copied and pasted the script. :(
     
  2. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    For a while I was thinking it was a SSL certificate problem.

    When I execute onElastix server:

    Code:
    [root@elastix ~]# curl https://localhost:8888/credit/credit_dialnow.php
    
    I get:

    curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
    error:14090086 SSL routines SL3_GET_SERVER_CERTIFICATE:certificate verify failed
    More details here: http://curl.haxx.se/docs/sslcerts.html

    curl performs SSL certificate verification by default, using a "bundle"
    of Certificate Authority (CA) public keys (CA certs). The default
    bundle is named curl-ca-bundle.crt; you can specify an alternate file
    using the --cacert option.
    If this HTTPS server uses a certificate signed by a CA represented in
    the bundle, the certificate verification probably failed due to a
    problem with the certificate (it might be expired, or the name might
    not match the domain name in the URL).
    If you'd like to turn off curl's verification of the certificate, use
    the -k (or --insecure) option.



    I do get output with (by switching off verification with -k option)

    Code:
    [root@elastix ~]# curl -k https://localhost:8888/credit/credit_dialnow.php
    6.14    <----------- OK !
    root@elastix ~]#
    
    I tried to change

    exten => 3000,n,Set(Status=${curl https://192.168.1.100:8888/credit/credit_dialnow.php)})

    into

    exten => 3000,n,Set(Status=${curl -k (https://192.168.1.100:8888/credit/credit_dialnow.php)})

    but variable ${Status} remains empty. :(<br><br>Post edited by: henkoegema, at: 2007/08/13 18:09
     
  3. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    This works: :)

    Code:
    [root@elastix ~]# status=$(curl -k https://192.168.1.100:8888/credit/credit_dialnow.php)
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     4    0     4    0     0      2      0 --:--:--  0:00:01 --:--:--    18
    [root@elastix ~]# echo $status
    4.46
    

    This doesn't: :(

    ......
    exten => 3000,n,Set(Status=${curl -k (https://192.168.1.100:8888/credit/credit_dialnow.php)})
    exten => 3000,n,NoOP(${Status})
    exten => 3000,n,SayDigits(${Status})
     
  4. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    Is the CURL function from Elastix a different one then the curl function from the operating system?

    (because the php script runs nicely from the os, but NOT from the dialplan in Elastix)
     
  5. henkoegema

    Joined:
    Jul 12, 2007
    Messages:
    37
    Likes Received:
    0
    I even tried to do a system call:

    Code:
    exten => 3000,1,Wait(1)
    exten => 3000,n,Playback(astcc-account-balance-is)
    exten => 3000,n,System(status=$(curl -k https://192.168.1.100:8888/credit/credit_dialnow.php))
    exten => 3000,n,System(echo ${status})
    exten => 3000,n,NoOP(${status})
    exten => 3000,n,SayDigits(${status})
    exten => 3000,n,Playback(vm-goodbye)
    exten => 3000,n,Hangup()
    
    But that gives me:


    -- Executing [3000@from-internal:2] Playback("Zap/1-1", "astcc-account-balance-is") in new stack
    -- <Zap/1-1> Playing 'astcc-account-balance-is' (language 'en')
    -- Executing [3000@from-internal:3] System("Zap/1-1", "status=$(curl -k https://192.168.1.100:8888/credit/credit_dialnow.php)") in new stack
    -- Executing [3000@from-internal:4] System("Zap/1-1", "echo ") in new stack
    -- Executing [3000@from-internal:5] NoOp("Zap/1-1", "") in new stack
    -- Executing [3000@from-internal:6] SayDigits("Zap/1-1", "") in new stack


    So it looks like that the variable ${status} gets lost. :blink:
     

Share This Page