Bonjour
je cherche la même fonction mais en perl svp
j'ai essayer ce lui la avce AGI mais il ya un énorme temps de réponse de 7 ou 8 seconde !!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 <? $host = 'localhost'; $port = 5038; $user = 'user'; $pass = '123456'; $context = 'home'; // the context your redirects are inside of $priority = '1'; // the default priority for redirects //End of variables section. function astconnect($action, $command, $host, $port, $user, $pass){ $socket = fsockopen($host, $port); fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: $user\r\n"); fputs($socket, "Secret: $pass\r\n\r\n"); fputs($socket, "Action: $action\r\n"); if (isset($command)) fputs($socket, "Command: $command\r\n\r\n"); fputs($socket, "Action: Logoff\r\n\r\n"); while (!feof($socket)) $wrets .= fread($socket, 8192); fclose($socket); return $wrets; } $cleanup = astconnect('Status', '', $host, $port, $user, $pass);
en+ la chaine retourné avec la fonction php est manipulable exp il ya ":" pour diviser la chaine en tab or que en perl c'est une chaine soudé que je peut pas la diviser pour extraire les variables!!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #!/usr/bin/perl # # Example script to show how to use Asterisk::Manager # # # use lib './lib', '../lib'; use Asterisk::Manager; $|++; my $astman = new Asterisk::Manager; $astman->user('user'); $astman->secret('123456'); $astman->host('localhost'); $astman->connect || die $astman->error . "\n"; for($i=0; $i=10000; $i++) { print STDERR $astman->sendcommand( Action => 'Status'); sleep(1); } $astman->disconnect;
la fonction va tourner en permanence pour enregistrer les donner dans mysql.
Merci
Partager