Asterisk AGI 无法执行 cURL

问题描述 投票:0回答:1

我正在使用 Bicom PBXware。我有复杂的 cURL,其中包含要使用 -H 发送的标头,这意味着我无法使用 Asterisk CURL 应用程序。所以我创建了可以正常工作的 bash 脚本:

/opt/pbxware/pw/var/lib/asterisk/agi-bin # cat resp_example.sh 
#!/bin/bash

resp=`/usr/bin/curl -s -H "Content-Type: application/json" -H "Card: 512912***" -H "Exp: 1125" -H "user: [email protected]" -H "Username: ***" -H "Api_token: ***" -X POST https://somewebsite/apiivr/getbalance`

#resp='{"result":true,"balance":"4315.94","message":"ok"}'

echo "SET VARIABLE resp '---> $resp'"

echo "NoOp resp: $resp"

因此这个 bash 脚本在 Linux CLI 中完美运行,但在 dialplan 中失败:

exten => 2006,1,AGI(resp_example.sh)
same => n,Hangup

我将所有内容更改为777,但仍然失败:

    /opt/pbxware/pw/var/lib/asterisk/agi-bin # ls -lah
    total 260K
drwxrwxrwx  2 root root 4.0K Sep  1 09:06 .
drwxr-xr-x 14  555  555 4.0K Sep  1 10:51 ..
-rwxrwxrwx  1 root root  100 Aug 31 05:51 CC-balance-process.agi
-rwxrwxrwx  1 root root  287 Sep  1 08:21 CCsetvars.agi
-rwxrwxrwx  1 root root 1.3K Sep  1 09:17 CCtest.agi
-rwxrwxrwx  1  555  555 1.3K Aug 31 16:59 CCtest.sh
-rwxrwxrwx  1 root root 1.8K Jan 17  2010 agi-test.agi
-rwxrwxrwx  1 root root  88K Jan 17  2010 eagi-sphinx-test
-rwxrwxrwx  1 root root 122K Jan 17  2010 eagi-test
-rwxrwxrwx  1 root root  15K Jan 17  2010 jukebox.agi
-rwxrwxrwx  1 root root  430 Sep  1 10:17 resp_example.sh

curl asterisk agi
1个回答
0
投票

首先,您应该检查星号用户是否可以运行该脚本(包括目录访问)

之后,你必须调试错误。

# stop asterisk
asterisk -r
core stop now
#start asterisk in console so you can see errors
asterisk -vvvgc
agi set debug on

ps 注意,星号有内部 func_CURL

© www.soinside.com 2019 - 2024. All rights reserved.