[asterisk-users] Writing own applications for asterisk - read CALLERIDNUM

Russell Bryant russell at digium.com
Thu Jul 20 05:12:14 MST 2006


On Thu, 2006-07-20 at 13:05 +0200, Matthias Fechner wrote:
> But I have now the problem that I cannot read the variable CALLERIDNUM
> from my script.
> 
> I tried it with:
> value = pbx_builtin_getvar_helper(chan, key);
> 
> where chan is the value given from the initial function call (struct
> ast_channel *chan) and key is set to "CALLERIDNUM".
> 
> But the function always returns NULL.

To access the callerid number inside an Asterisk application, you access
it directly on the channel structure.

ast_verbose("The channel cid num is: %s\n", chan->cid.cid_num);

To set it, use the ast_set_callerid() function, which is defined in
include/asterisk/channel.h.  The third argument is for changing the
name, and the fourth is for ANI.

ast_set_callerid(chan, "12564286000", NULL, NULL);

I hope this helps,

-- 
Russell Bryant
Software Developer
Digium, Inc.




More information about the asterisk-users mailing list