On Sunday, August 7, 2016 3:32:32 PM CDT Alex Balashov wrote: > On 08/07/2016 03:13 PM, Anthony Joseph Messina wrote: > > I'm trying to play around a bit with app_python using the examples in the > > source. I'd like to access the content of the body of the SIP message, > > but > > can't figure out how to do that. I can get headers, method, etc. How > > does > > one access body content with app_python? > > You can pass the appropriate PV ($rb) as the second argument to > python_exec(): > > http://kamailio.org/docs/modules/4.4.x/modules/app_python.html#idp18178284 > > In the Python script, you can fish it out with the handler function > called in the first argument to python_exec(). If you're concerned about > delimiters and serialisation, you can base64-encode it with > {s.encode.base64}. > > python_exec() only accepts two arguments, so if you need to pass in more > data, your best bet is to use the 'jansson' module to construct a JSON > blob and pass that in as the argument. On the Python side: > > import json > > > ... > class WhateverModule: > ... > def handler_func(self, msg, args): > obj = json.loads(args) > > -- Alex
Thanks Alex. I guess I was thinking that the whole message would be available from within app_python. This works well. -A -- Anthony - https://messinet.com/ - https://messinet.com/~amessina/gallery F9B6 560E 68EA 037D 8C3D D1C9 FF31 3BDB D9D8 99B6
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users