gpt4 book ai didi

php - 用 php 为 Asterisk AMI 分离部分 fread 输出

转载 作者:太空宇宙 更新时间:2023-11-04 12:01:54 26 4
gpt4 key购买 nike

我有一个问题让我最近几天一直很忙。我正在使用 Asterisk AMI。

AMI 给出这样的输出。

    Event: RTCPSent
Privilege: reporting,all
Channel: SIP/1001-00000000
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten: 1000
Priority: 4
Uniqueid: 1535617422.0
Linkedid: 1535617422.0
To: 111.108.30.208:61987
From: 172.31.21.5:20687
SSRC: 0x5847ea3c
PT: 200(SR)

Event: RTCPReceived
Privilege: reporting,all
Channel: SIP/1001-00000000
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten: 1000
Priority: 4
Uniqueid: 1535617422.0
Linkedid: 1535617422.0
To: 172.31.21.5:20687
From: 111.108.30.208:61987
RTT: 0.0116
SSRC: 0x235022ee
PT: 200(SR)

Event: RTCPSent
Privilege: reporting,all
Channel: SIP/1000-00000001
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 1000
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten:
Priority: 1
Uniqueid: 1535617431.1
Linkedid: 1535617422.0
To: 111.108.30.208:61044
From: 172.31.21.5:20349
SSRC: 0x0cb019a0
PT: 200(SR)

Event: RTCPReceived
Privilege: reporting,all
Channel: SIP/1000-00000001
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 1000
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten:
Priority: 1
Uniqueid: 1535617431.1
Linkedid: 1535617422.0
To: 172.31.21.5:20349
From: 111.108.30.208:61044
RTT: 0.0115
SSRC: 0x00294823
PT: 200(SR)

我使用 fread() 函数收集输出。

fread($fp, 8192);

[$fp 是上面的输出]

这可行,但逐行给出输出。获得此信息的正确方法是从空白行到空白行。

    Event: RTCPReceived
Privilege: reporting,all
Channel: SIP/1001-00000000
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: SIP/1001
ConnectedLineNum: <unknown>
ConnectedLineName: SIP/1001
Language: ja
AccountCode:
Context: phones
Exten: 1000
Priority: 4
Uniqueid: 1535617422.0
Linkedid: 1535617422.0
To: 172.31.21.5:20687
From: 111.108.30.208:61987
RTT: 0.0116
SSRC: 0x235022ee
PT: 200(SR)

这样我就可以收集所需的信息并执行以下步骤。

这可以用 fread 函数实现吗?

我需要阅读信息,例如谁接了电话或挂断电话。

您的意见将一如既往地受到高度赞赏

最佳答案

不,不可能。

您应该逐行读取循环中的行,直到得到空行并在需要时将其合并到缓冲区中。

关于php - 用 php 为 Asterisk AMI 分离部分 fread 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52092557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com