Koozali.org: home of the SME Server

click-to-call and egroupware [DONE]

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
click-to-call and egroupware [DONE]
« on: April 01, 2008, 01:29:08 AM »
(Note: this post has been modified)

Egroupware can be used to call a contact.
In addressbook -> Site configuration, set the link to something like:
http://selintra/pbx/call.php?number=%1&accountname=%u&accountphone=%t

Where http://selintra is you PBX box,
/pbx/call.php is the name of the script.

Use a script like this one to execute the call. It must be adapted though...
Code: [Select]
$strHost = "127.0.0.1";
$strWaitTime = "30";
$strPriority = "1";
$strMaxRetry = "2";

$strUser = "<as defined in manager.conf>";
$strSecret = "<as defined in manager.conf>";

# match context or cluster
$strContext = "internal";

# get parameters
$strChannel = "SIP/<YOUR_EXTENSION>;
$number=strtolower($_REQUEST['number']);
$number=ereg_replace("[^A-Za-z0-9]", "", $number);

# quick validation:

if ($number == null) :  exit() ; endif ;
$length = strlen($number); if ($length < 10):  exit() ; endif ;

# action:

$errno=0 ;
$errstr=0 ;
$strCallerId = "Web Call <$number>";
$oSocket = fsockopen ("localhost", 5038, &$errno, &$errstr, 20);

if (!$oSocket) {
  echo "$errstr ($errno)<br>\n";
} else {
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $number\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(2);
fclose($oSocket);
}

« Last Edit: April 06, 2008, 07:34:43 PM by soprom »
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call
« Reply #1 on: April 01, 2008, 02:59:53 AM »
The code gives an error with
Code: [Select]
channel.c:2818 __ast_request_and_dial: Unable to request channel SIP/5100
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call
« Reply #2 on: April 05, 2008, 08:14:55 AM »

Nobody is using click-to-call ?
Sophie from Montréal

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: click-to-call
« Reply #3 on: April 05, 2008, 08:26:57 AM »
This is standard php yes?

It isn't SAIL dependent, except for the context (which for an outbound call should be set to "internal").  It is using the asterisk manager interface to instigate a call.  Have you written this or has it come from a TBox site?  Either way it should work just fine in exactly the same way as it did wherever it came from.

Kind Regards

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #4 on: April 06, 2008, 05:31:37 PM »
it works...
I modified the first post.
Sophie from Montréal

Offline Franco

  • *
  • 1,171
  • +0/-0
    • http://contribs.org
Re: click-to-call and egroupware [DONE]
« Reply #5 on: April 08, 2008, 10:00:22 PM »
Hi,
This is very interesting!
Does the client uses a web application or does this script invokes a e-groupware app?

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #6 on: April 08, 2008, 11:00:40 PM »
The script in the first post is placed on the PBX.
I created an IBAY (no internet access) to store those scripts.
EGroupware is then configured to call it.

The way it works is that a click on the phonenumber in the address book is linked to the script. Then the specified extension is called (my phone). If I pickup the phone, the system then calls the number obtained from the address book.
« Last Edit: April 08, 2008, 11:02:47 PM by soprom »
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #7 on: April 09, 2008, 02:10:59 AM »
Corrections are needed on the script:

These lines:
$strHost = "127.0.0.1";
$oSocket = fsockopen ("localhost", 5038, &$errno, &$errstr, 20);

Are changed to:
$strHost = "192.168.X.Y"; // address of pbx as in manager.conf bindaddr=192.168.X.Y
$oSocket = fsockopen ($strHost, 5038, &$errno, &$errstr, 20);

Sophie from Montréal

Offline Franco

  • *
  • 1,171
  • +0/-0
    • http://contribs.org
Re: click-to-call and egroupware [DONE]
« Reply #8 on: April 09, 2008, 04:33:30 AM »
Hello,
I'm trying to get this to work.
Where do I find:
Code: [Select]
$strUser = "<as defined in manager.conf>";

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #9 on: April 09, 2008, 05:00:59 AM »
Look in manager.conf to see what is the username.
It should be remote_mgr between brackets ([remote_mgr]). Password will be the secret in the same section.

In other words, the usename is the title of the section (between brackets).

The bindaddr=x.x.x.x in the section [general] will tell you what to set as host.
This should your lan PBX's ip.
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #10 on: April 09, 2008, 06:11:32 AM »
If you define the link in EGroupware as shown in the first post, you can also create a custom field in the address book named pbx_extension to store a value for $strChannel.

Remember not to allow internet access to this script...

This code will get the extension for the user who clicked the link:
Code: [Select]
$strChannel = ""; // instead of $_REQUEST['exten'];
$accountname= $_REQUEST['accountname'];
$account= $_REQUEST['account'];

$egwHost="x.x.x.x"; // server running egroupware
$egwUser="xxxxx";  // username to access through lan
$egwPass="xxxxx";  // password for that user
$egwData="xxxxx";  // database name like egroupware

$connect = TRUE;
$connect = mysql_connect($egwHost,$egwUser,$egwPass) or die("Pas de connexion au serveur");
mysql_select_db($egwData, $connect) or die("Pas de connexion à la base");

$query = "
SELECT
egw_addressbook.account_id,
egw_addressbook_extra.contact_name,
egw_addressbook_extra.contact_value,
egw_accounts.account_lid
FROM
(egw_addressbook
INNER JOIN egw_addressbook_extra
ON egw_addressbook.contact_id =egw_addressbook_extra.contact_id)
INNER JOIN egw_accounts
ON egw_addressbook.account_id = egw_accounts.account_id
WHERE
(((egw_addressbook_extra.contact_name)='pbx_extension')
AND ((egw_accounts.account_lid)='".$accountname."'));";

//echo "<br>Requete:".$query;

$result = mysql_query($query) or die ("Exécution de la requête impossible");
$row = mysql_fetch_array($result);
$strChannel = $row[contact_value];
mysql_close();
//echo "<br>Extension : " .$strChannel;

I'm no expert in php but this works!
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #11 on: April 10, 2008, 06:13:39 AM »
Don't forget to enable mysql on the lan if using 2 different machines:
Code: [Select]
config setprop mysqld LocalNetworkingOnly no
 expand-template /etc/my.cnf
 /etc/rc.d/init.d/mysqld restart
Sophie from Montréal

Offline fpausp

  • *
  • 728
  • +0/-0
Re: click-to-call and egroupware [DONE]
« Reply #12 on: April 10, 2008, 09:23:55 PM »
Hi soprom,

I like to test click-to-call, i tried your description but something went wrong, can you please write a more detailed how to for us ?

regards
fpausp
Viribus unitis

Offline Franco

  • *
  • 1,171
  • +0/-0
    • http://contribs.org
Re: click-to-call and egroupware [DONE]
« Reply #13 on: April 10, 2008, 09:27:43 PM »
Hi soprom,

I like to test click-to-call, i tried your description but something went wrong, can you please write a more detailed how to for us ?

regards
fpausp

I couldn't get it to work either :(

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #14 on: April 11, 2008, 03:12:54 AM »
I'm sorry to see that you have problems with my posts. I know I was not very coherent.
Here is a howto I just wrote for you. The script I'm proposing is the script I currently use, edited for the howto.

The adress is:
http://www.logiciel-libre.org/?Produits:EGroupware:Int%E9gration_PBX:Howto

ps

1. Montréal is actually winning over Boston and the howto could have suffered from that!!!
2. And no, it's not me on the photo on my web site
Sophie from Montréal

Offline fpausp

  • *
  • 728
  • +0/-0
Re: click-to-call and egroupware [DONE]
« Reply #15 on: April 12, 2008, 11:26:49 PM »
Hello soprom,

Thanks for your wonderful howto, i have done all the steps but i got:

Error with socket for 1234567890

How can i fix this ?


regards
fpausp
Viribus unitis

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #16 on: April 13, 2008, 12:16:34 AM »
Try to give a little more info...
- Are PBX and Egroupware on the same machine?
- What is the link under the phone number in the addressbook?

Change the line after $oSocket like this, in order to hae more info on the error:

if (!$oSocket) {
   echo "<br>Error with socket for $number error $errno $errstr";
« Last Edit: April 13, 2008, 01:38:43 AM by soprom »
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #17 on: April 13, 2008, 01:52:20 AM »
Error creating a socket must have to do with permissions. So you might check that pbx address and manager account are ok.
Sophie from Montréal

Offline fpausp

  • *
  • 728
  • +0/-0
Re: click-to-call and egroupware [DONE]
« Reply #18 on: April 13, 2008, 10:14:40 AM »
Hi,

Quote
Try to give a little more info...
- Are PBX and Egroupware on the same machine?
- What is the link under the phone number in the addressbook?

Change the line after $oSocket like this, in order to hae more info on the error:

if (!$oSocket) {
   echo "<br>Error with socket for $number error $errno $errstr";

1. PBX and Egroupware are on the same machine
2. The link is: http://192.168.1.246/pbx/call.php?number=1234567890&accountname=admin&account=5000
3. I changed the line, the output is: Error with socket for 1234567890 error 111 Connection refused
Viribus unitis

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #19 on: April 13, 2008, 04:36:49 PM »
First, check in manager.conf since I forgot to mention a change in [general]. See below.

Double-check that manager.conf has the same username and secret as in your script;
if you kept the default one, it should look like this:

(if PBX=192.168.1.246)

[remote_mgr]
secret=0chanc3yo
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
;
;Allow LAN connections
permit=192.168.1.0/255.255.255.0
;
;writetimeout=100
;Authorization
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user
;

I see that I forgot to mention this change in manager.conf:

[general]
enabled=yes
port=5038
;bindaddr=127.0.0.1
;
;Listen on the LAN interface
bindaddr=192.168.1.246

;
displayconnects=yes
;

Call.php should have matching lines:

# pbx server address:
$strHost = "192.168.1.246";   

#specify the username you want to login with (in /etc/asterisk/manager.conf)
$strUser = "remote_mgr;

#specify the password for the above user
$strSecret = "0chanc3yo";   


Jeff could confirm this, but I think that asterisk must be restarted, not just reloaded.
For your tests, use the default manager account and be patient, I had the same issue and asterisk will accept connections.

Use this command to see the account on the PBX:

pbx*CLI> manager show user remote_mgr
       username: remote_mgr
         secret: <Set>
           deny: 0.0.0.0/0.0.0.0
         permit: 192.168.1.0/255.255.255.0
           read: system,call,log,verbose,command,agent,user
          write: system,call,log,verbose,command,agent,user
displayconnects: no
« Last Edit: April 13, 2008, 04:58:48 PM by soprom »
Sophie from Montréal

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: click-to-call and egroupware [DONE]
« Reply #20 on: April 13, 2008, 05:54:41 PM »
in theory you should be able to do "reload manager" at the console but "restart now" is fewer letters anyway :)

Best

J

 

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #21 on: April 13, 2008, 08:45:23 PM »
Also, the script must take care of the cluster needed for outbound calls.
The 'default' cluster must be replaced with a cluster matching the extension called.

For that, the custom field in addressbook must be lenghten to allow for a cluster name.
I modified the script by adding this just before mysql_close();:

Code: [Select]
# Get the extension to use in the call back
# $strChannel = $row[contact_value];
list ($strContext, $strChannel) = split('[|]',$row[contact_value]);
if (strlen($strContext)==0):
$strContext = "default";
endif ;
mysql_close();

The new format for the custom field data is : "cluster_name|SIP/5000"
Without any cluster defined it should then be : "default|SIP/5000"


Sophie from Montréal

Offline fpausp

  • *
  • 728
  • +0/-0
Re: click-to-call and egroupware [DONE]
« Reply #22 on: April 13, 2008, 09:03:17 PM »
Hi,

Thank you very much, it is working now. Lets try Caller Info :-).


Best
fpausp

Viribus unitis

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #23 on: April 13, 2008, 10:07:30 PM »
I'm glag you like it!!!
The tricky part with Caller info is to handle YAACID numerous options...

I'll add some notes to the post about it.
Sophie from Montréal

Offline sonoracomm

  • *
  • 208
  • +0/-0
    • http://www.sonoracomm.com
Re: click-to-call and egroupware [DONE]
« Reply #24 on: April 17, 2008, 11:20:13 PM »
Hi Sophie,

Thanks very much for sharing this howto with us.

However, I was unable to make it work using a single SME server.

Apparently, there are many variables plus my lack of understanding of PHP keeping me from success.

As I tried to work through the howto, I ran into several 'issues':

1)  What about a configuration with just one server?  Are the instructions similar?

2)  When enabling LAN access "db configuration setprop mysqld variable value" must not be correct?

3) The GRANT command errors out with a syntax error. (may just need quotes?)

4) When creating the i-Bay, you must allow reading from 'everyone' I think?

5) When posting the call.php file, it must go in the 'html' folder, yes?

6) Does your download-able script still need to be modified for cluster awareness? Is that necessary?

In the end, if I followed the instructions as closely as possible, I get:

Failed to connect to server 192.168.0.1.

Might you have any troubleshooting tips for me?

Thanks in advance,

G

Offline sonoracomm

  • *
  • 208
  • +0/-0
    • http://www.sonoracomm.com
Re: click-to-call and egroupware [DONE]
« Reply #25 on: April 17, 2008, 11:52:49 PM »
OK, to partly answer my own...

I'm guessing this is the command to open up the mysql networking:

Code: [Select]
config setprop mysqld LocalNetworkingOnly no
After I do that, I get the pop-up:

Code: [Select]
Extension
Number 5206611293
Username admin
Originating number
Close this window

However neither 'Extension' nor 'Originating number' is populated.

???

Thanks again,

G
« Last Edit: April 18, 2008, 12:21:40 AM by sonoracomm »

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #26 on: April 17, 2008, 11:53:08 PM »
Hi sonoracomm , I'm a fan of your web site!

I'm sorry to see you have problems with click-to-call... But you might not be that far away...

The first edition of the how was missing an important thing:

Add "permit=192.168.0.0/255.255.255.0" in manager.conf, under the username section like this example:

[remote_mgr]
secret=0chanc3yo
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
;
;Allow LAN connections
permit=192.168.0.0/255.255.255.0
;

;writetimeout=100
;Authorization
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user
;

1)  What about a configuration with just one server?  Are the instructions similar?
For a single machine setup the egroupware server ip address is the same as the pbx ip address.

2)  When enabling LAN access "db configuration setprop mysqld variable value" must not be correct?
For a single machine setup, this is not needed. You are right, the correct command should be:
db configuration setprop mysqld LocalNetworkingOnly  no

3) The GRANT command errors out with a syntax error. (may just need quotes?)
The howto presents the command on multiple lines. You might want to try with a single line command.

4) When creating the i-Bay, you must allow reading from 'everyone' I think?
I prefer admin (as user and group) because there are files with passwords.

5) When posting the call.php file, it must go in the 'html' folder, yes?
Yes so that it can be executed.

6) Does your download-able script still need to be modified for cluster awareness? Is that necessary?
Yes the script is updated and cluster handling appears to be required.

Thank you for helping me to get my howto better!

Sophie
« Last Edit: April 18, 2008, 12:33:20 AM by soprom »
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #27 on: April 18, 2008, 12:05:22 AM »
The username "admin" that you are using is defined in Egroupware and should have its custom field (addressbook) set to something like :
default|SIP/5000

"Number" should show the number you are calling,
"Originating number" is from the link variable "account" (egroupware)

There might be a problem with the link parameters typed in egroupware.
Sophie from Montréal

Offline sonoracomm

  • *
  • 208
  • +0/-0
    • http://www.sonoracomm.com
Re: click-to-call and egroupware [DONE]
« Reply #28 on: April 18, 2008, 01:00:31 AM »
Hello again,

Thanks much for your assistance.

I did finally understand that I was logged into eGroupware as 'admin' and that that was the reason the pop-up showed 'admin'.

Also, your recommendation to include the context (cluster) in the custom eGroupware extension field did enable me to dial.

However, I still don't understand this:
Quote
"Originating number" is from the link variable "account" (egroupware)

The link I have entered in "Telephony integration" is:
Quote
http://192.168.0.1/pbx/call.php?number=%1&accountname=%u&account=%t

but I don't really understand it.  'number' seems obvious, but 'accountname' and 'account', not so much.  I understand they are being pulled from the eGroupware database, but I don't understand the 'what' or the 'why'.

Is there any documentation on any of this?  I have been unable to find any save:

Quote
  Telephony integration:

    * Input field URL to link telephone numbers to: : use %1 = number to call, %u = account name, %t = account phone
    * Input field Size of popup: WxH, eg.400x300, if a popup should be used

At this point, the script is functioning, but it dials out using the wrong trunk every time.  It doesn't seem to follow the outbound SARK settings.

Thanks,

G

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #29 on: April 18, 2008, 01:25:52 AM »
I'm glad you are progressing. I had problems too and that motivated the howto.

You are quite right about naming the variable "account". It would be better to name it "account_phone".

Concerning documentation for the click-to-call, it's in the Egroupware Book and of which there is a sample chapter on the web. I think it's where I found that.

Dialing out is managed by the outbound route belonging to a cluster. You must then make sure you are using valid cluster. I don't know if context "internal" would work.

The accountname is needed because the mysql queries can find the contact_id from it. Then the script gets the extension saved in the custon field for that contact_id. This extension is finally split into cluster and channel to initiate the call.

Hope that helped...
Sophie from Montréal

Offline sonoracomm

  • *
  • 208
  • +0/-0
    • http://www.sonoracomm.com
Re: click-to-call and egroupware [DONE]
« Reply #30 on: April 18, 2008, 09:30:57 PM »
Hello again,

Sorry to be a pain...

I think there must be a bug in the script.  No matter which context (internal) or 'cluster' (default) I use in the custom database field, the pop-up does not display an "Originating number" and it always uses the wrong trunk to dial out on.  It does not use the normal outbound trunk selection and I need it to dial out on a ZAP trunk like normal outbound calls.

Unfortunately, no matter how hard I stare at the script, I don't understand how it actually sends the dialing commands to Asterisk.

Might the problem be due to the empty "Originating number"?

Here is the Asterisk console output:

Code: [Select]
  == Parsing '/etc/asterisk/manager.conf': Found
  == Manager 'remote_mgr' logged on from 192.168.0.1
       > Channel SIP/4101-0980f6c0 was answered.
  == Manager 'remote_mgr' logged off from 192.168.0.1
    -- Executing [5206611293@internal:1] AGI("SIP/4101-0980f6c0", "selintra|OutCluster|5206611293") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/selintra
    -- AGI Script selintra completed, returning 0
    -- Executing [5206611293@default:1] Set("SIP/4101-0980f6c0", "CALLERID(name)=Sonora Comm") in new stack
    -- Executing [5206611293@default:2] AGI("SIP/4101-0980f6c0", "selintra|OutTrunk|west.voipjet.com") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/selintra
    -- AGI Script Executing Application: (Dial) Options: (IAX2/7823@voipjet/15206611293)
    -- Called 7823@voipjet/15206611293
    -- Call accepted by 8.3.22.250 (format ulaw)
    -- Format for call is ulaw
    -- IAX2/voipjet-4 is making progress passing it to SIP/4101-0980f6c0
    -- IAX2/voipjet-4 answered SIP/4101-0980f6c0
    -- Hungup 'IAX2/voipjet-4'
  == Spawn extension (default, 5206611293, 2) exited non-zero on 'SIP/4101-0980f6c0'
    -- Executing [h@default:1] Hangup("SIP/4101-0980f6c0", "") in new stack
  == Spawn extension (default, h, 1) exited non-zero on 'SIP/4101-0980f6c0'

And here is the pop-up:

Code: [Select]
Extension SIP/4101
Number 5206611293
Username admin
Originating number
Close this window

I believe the communication with the mysql server and Asterisk are working properly.  I suspect the problem is in the dialing commands being sent to Asterisk.

Thanks much,

G

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #31 on: April 18, 2008, 10:04:59 PM »
I wish I could help you right away but it will have to be later this weekend.
In the mean time, can you tell me if your extension rings and if your hear your extension dialing something when your pick it up?

And what is the phone number associated with the account "admin' in egroupware? Would it be empty?

The custom field in egroupware's addressbook should be looking like
default|SIP/4101
« Last Edit: April 19, 2008, 01:20:32 AM by soprom »
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Re: click-to-call and egroupware [DONE]
« Reply #32 on: April 19, 2008, 01:18:11 AM »
From the log, it seems that the script worked since the extension was answered and the call was initiated. I can't say if the script or the pbx is to be investigated first.

The "originating number" is not use by asterisk, just displayed in the popup.

Are you using any cluster at all? Choosing a specific trunk to dialout is not done in the script. It must be in the extension and route config I think.


Notes about dialing. Dialing is done with this:

First the login...
Code: [Select]
$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection to PBX failed");
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");

then calling the extension (like SIP/5000)...

Code: [Select]
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");

finaly, calling the number using a context...

Code: [Select]
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $strExten\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(2);
fclose($oSocket);

In fact, in its simple form, sending parameters and action code followed by 2 empty lines ("\r\n\r\n") is interpreted in asterisk as a command and the PBX executes the command.

« Last Edit: April 19, 2008, 01:51:30 AM by soprom »
Sophie from Montréal