This topic is locked

How to use TAPI via vbs

2/3/2011 8:18:30 AM
PHPRunner General questions
S
snuffi01 author

Hi!
I want to be able to click an hyperlink in PHPrunner website witch uses an vbs file to call an phone call via TAPI in an windows machine.
I have found an vbScript witch look like this:
Option Explicit
Dim strFilter, strNumber

strFilter = ""
If (Wscript.Arguments.Count < 1) Then

Wscript.Echo "Make a call via TAPI" & vbcrlf & vbcrlf & "dial.vbs Number StringToSearchForInTapi"

Wscript.Quit

Else

' Retrieve the first argument (index 0).

strNumber = Wscript.Arguments(0)

If Wscript.Arguments.Count > 1 Then

' Retrieve the second argument.

strFilter = Wscript.Arguments(1)

End If

End If
If Wscript.Arguments(0) = "-list" Then

Call ListTAPI()

Else

Call MakeCall(strNumber, strFilter)

End If
Sub MakeCall(strNumber, strFilter)

Dim lAddressType, objTapi, objCollAddresses, objCrtAddress, lLoop, NewCall, gobjAddress
Const LINEADDRESSTYPE_PHONENUMBER = 1

Const LINEMEDIAMODE_INTERACTIVEVOICE = 4
lAddressType = LINEADDRESSTYPE_PHONENUMBER

Set objTapi = CreateObject("TAPI.TAPI.1")

objTapi.Initialize

Set objCollAddresses = objTapi.Addresses
For lLoop = 1 To objCollAddresses.Count

Set objCrtAddress = objCollAddresses.Item(lLoop)

If Instr(objCrtAddress.AddressName, "IP Phone:") > 0 Then

If Instr(objCrtAddress.AddressName, strFilter) Then

Set gobjAddress = objCrtAddress

Exit For

End If

End If

If lLoop = objCollAddresses.Count Then

Msgbox "TAPI Provider Not Found"

WScript.quit(-1)

End If

Next
Set NewCall = gobjAddress.CreateCall(strNumber, lAddressType, LINEMEDIAMODE_INTERACTIVEVOICE) ',lMediaTypes)'Set

NewCall.connect(False)
End Sub
Sub ListTAPI()

Dim strAddressList, lAddressType, objTapi, objCollAddresses, objCrtAddress, lLoop
Const LINEADDRESSTYPE_PHONENUMBER = 1
lAddressType = LINEADDRESSTYPE_PHONENUMBER

Set objTapi = CreateObject("TAPI.TAPI.1")

objTapi.Initialize

Set objCollAddresses = objTapi.Addresses
For lLoop = 1 To objCollAddresses.Count

Set objCrtAddress = objCollAddresses.Item(lLoop)

strAddressList = strAddressList & objCrtAddress.AddressName & vbCrLf

Next

Wscript.echo strAddressList

End Sub
How should i use this vbs in phprunner to make it possible to click an phonenumber field in the website and the the local win maschine uses the vbs to call thrue TAPI?

Admin 2/4/2011

You won't be able to use VBscript code with PHPRunner. You either need to find PHP equivalent of this code or use it in ASPRunnerPro.

S
snuffi01 author 2/4/2011

Ok,

How about this code then?
$tapi = new COM("TAPI.TAPI.1");

$res = $tapi->Initialize();

$objCollAddresses = $tapi->Addresses;

for($i = 1; $i <= $objCollAddresses->Count; $i++)

{

if(strpos($objCrtAddress->AddressName, IP_OFFICE_PHONE) !== false)

{

$gobjAddress = $objCollAddresses->Item($i);

}

}

if($gobjAddress != null)

{

$NewCall = $gobjAddress->CreateCall("xxxxxxxxx",

LINEADDRESSTYPE_PHONENUMBER,

LINEMEDIAMODE_INTERACTIVEVOICE);

$NewCall->connect(false);

sleep(50);

$NewCall->Disconnect(DC_NORMAL);

}

$res = $tapi->Shutdown();