On 07/08/16 21:40, Anthony Joseph Messina wrote: > 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 If you want to play with upcoming kamailio 5.0 (master branch now), look at:
- https://www.kamailio.org/wiki/devel/config-engines#python_config_kemi_engine - https://github.com/kamailio/kamailio/blob/master/examples/kemi/kamailio-basic-kemi-python.py Cheers, Daniel -- Daniel-Constantin Mierla http://www.asipto.com - http://www.kamailio.org http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda _______________________________________________ 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