Can API commands return something other than CSV?
I'm connecting to FS from PHP over a socket, and parsing results using the php function str_getcsv() In my dialplan I have: <action application="playback" data="tone_stream://%(250,250,600,120)"/> When I run "api show channels" if a channel is currently playing that tone, then within the returned results I get these 3 headers and values: <snip>,application,application_data,dialplan,<snip> <snip>,playback,tone_stream://%(250,250,600,120);loops=3,XML,<snip> So the data-separator is the comma, but the data also contains commas without being escaped in any way. Is there any way to change the results to be returned in json? Or change the delimiter? I've made a regex replace to get around this particular case by matching parentheses... But I can see this happening again with some other value that has a comma outside of parentheses, and would rather get the results in a better format if possible. (In the wiki, I can see that CDRs and events can be sent in json, and the serialize command for events, but none of those would help this particular case.) Cheers, Fraser
show channels as json show channels as xml show channels as csv <optional delim> On Wed, Dec 18, 2013 at 2:30 PM, Fraser Redmond <fraserredmond@gmail.com>wrote:
I'm connecting to FS from PHP over a socket, and parsing results using the php function str_getcsv()
In my dialplan I have: <action application="playback" data="tone_stream://%(250,250,600,120)"/>
When I run "api show channels" if a channel is currently playing that tone, then within the returned results I get these 3 headers and values: <snip>,application,application_data,dialplan,<snip> <snip>,playback,tone_stream://%(250,250,600,120);loops=3,XML,<snip>
So the data-separator is the comma, but the data also contains commas without being escaped in any way.
Is there any way to change the results to be returned in json? Or change the delimiter?
I've made a regex replace to get around this particular case by matching parentheses... But I can see this happening again with some other value that has a comma outside of parentheses, and would rather get the results in a better format if possible.
(In the wiki, I can see that CDRs and events can be sent in json, and the serialize command for events, but none of those would help this particular case.)
Cheers, Fraser
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II ♬ @anthmfs ♬ @FreeSWITCH ♬ ☞ http://freeswitch.org/ ☞ http://cluecon.com/ ☞ http://twitter.com/FreeSWITCH ☞ irc.freenode.net #freeswitch ☞ *http://freeswitch.org/g+ <http://freeswitch.org/g+>* ClueCon Weekly Development Call ☎ sip:888@conference.freeswitch.org ☎ +19193869900
Great, thanks Tony and Erik! I've added a mention of that to https://wiki.freeswitch.org/wiki/Mod_commands#Core_Commands so that anyone else that searches the wiki for json might find it. Could someone add it to the brief "help" output in fs_cli? (I haven't made the leap to FS development yet.) Cheers, Fraser On 18 December 2013 20:50, Anthony Minessale <anthony.minessale@gmail.com>wrote:
show channels as json show channels as xml show channels as csv <optional delim>
On Wed, Dec 18, 2013 at 2:30 PM, Fraser Redmond <fraserredmond@gmail.com>wrote:
I'm connecting to FS from PHP over a socket, and parsing results using the php function str_getcsv()
In my dialplan I have: <action application="playback" data="tone_stream://%(250,250,600,120)"/>
When I run "api show channels" if a channel is currently playing that tone, then within the returned results I get these 3 headers and values: <snip>,application,application_data,dialplan,<snip> <snip>,playback,tone_stream://%(250,250,600,120);loops=3,XML,<snip>
So the data-separator is the comma, but the data also contains commas without being escaped in any way.
Is there any way to change the results to be returned in json? Or change the delimiter?
I've made a regex replace to get around this particular case by matching parentheses... But I can see this happening again with some other value that has a comma outside of parentheses, and would rather get the results in a better format if possible.
(In the wiki, I can see that CDRs and events can be sent in json, and the serialize command for events, but none of those would help this particular case.)
Cheers, Fraser
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II ♬ @anthmfs ♬ @FreeSWITCH ♬
☞ http://freeswitch.org/ ☞ http://cluecon.com/ ☞ http://twitter.com/FreeSWITCH ☞ irc.freenode.net #freeswitch ☞ *http://freeswitch.org/g+ <http://freeswitch.org/g+>*
ClueCon Weekly Development Call ☎ sip:888@conference.freeswitch.org ☎ +19193869900
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Fraser Does "api show calls as xml" work for you? From the command line, "show calls as xml" gives me - http://pastebin.com/8ucMS4WL. Erik On Wed, Dec 18, 2013 at 2:30 PM, Fraser Redmond <fraserredmond@gmail.com>wrote:
I'm connecting to FS from PHP over a socket, and parsing results using the php function str_getcsv()
In my dialplan I have: <action application="playback" data="tone_stream://%(250,250,600,120)"/>
When I run "api show channels" if a channel is currently playing that tone, then within the returned results I get these 3 headers and values: <snip>,application,application_data,dialplan,<snip> <snip>,playback,tone_stream://%(250,250,600,120);loops=3,XML,<snip>
So the data-separator is the comma, but the data also contains commas without being escaped in any way.
Is there any way to change the results to be returned in json? Or change the delimiter?
I've made a regex replace to get around this particular case by matching parentheses... But I can see this happening again with some other value that has a comma outside of parentheses, and would rather get the results in a better format if possible.
(In the wiki, I can see that CDRs and events can be sent in json, and the serialize command for events, but none of those would help this particular case.)
Cheers, Fraser
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (3)
-
Anthony Minessale
-
Erik M. Devane - Comms Guy
-
Fraser Redmond