Skip to content

Instantly share code, notes, and snippets.

@yassinelachgar
Created July 16, 2025 09:40
Show Gist options
  • Save yassinelachgar/b87849a2b7ad6b80a16adc195b0fc47d to your computer and use it in GitHub Desktop.
Save yassinelachgar/b87849a2b7ad6b80a16adc195b0fc47d to your computer and use it in GitHub Desktop.
agi_http_trigger.py
#!/usr/bin/env python2
import sys
import urllib2
def read_agi_variables():
agi_vars = {}
while True:
line = sys.stdin.readline().strip()
if not line:
break
parts = line.split(':', 1)
if len(parts) == 2:
key, value = parts
agi_vars[key.strip()] = value.strip()
return agi_vars
def main():
agi_env = read_agi_variables()
# Call the URL
try:
url = "http://192.168.30.111:10014/freepbx/demo"
response = urllib2.urlopen(url)
content = response.read()
sys.stdout.write('VERBOSE "HTTP Call success: %s" 3\n' % content)
except Exception as e:
sys.stdout.write('VERBOSE "HTTP Call failed: %s" 1\n' % str(e))
# End AGI cleanly
sys.stdout.write("ANSWER\n")
sys.stdout.write("HANGUP\n")
sys.stdout.flush()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment