Page 1 of 1

Making Skype phone calls and sms

Posted: Wed Nov 14, 2007 10:38 am
by AHF
I've been trying with the code below but it doesn't work.

FUNCTION PhoneTO(cPhone,cNome,cComment)
Local oSkype,oCall,oUser


cPhone := alltrim(cPhone)

Try
oSkype := CreateObject("Skype4COM.Skype")
Catch
alert("Skype4Com não está instalado!")
return
End

If .not. oSkype:Client:IsRunning()
MsgRun("Informação","Activando o Skipe",{||oSkype:Client:Start()})
Endif

Try
oCall := oSkype:PlaceCall(cphone)
Catch
MsgInfo("Chamada falhada! Telefone: "+cPhone)
return 0
End

oSkype := Nil
RETURN 1

I get the following error :

Args:
[ 1] = C 'echo123'
argumentos { 'echo123' }
descrição E_FAIL
ficheiro <nenhuma>
genCode 41: Unknown or reserved
operação PLACECALL
osCode (Não é erro do sistema operativo)
severity 2
subCode 16389
subSystem SKYPE4COM.Skype
tries 0

Does anyone knows how to work with it ?
I've chech already this newsgroup but the code I've found it's for old API.

Regards
Antonio

Posted: Wed Nov 14, 2007 6:41 pm
by dutch
Dear AHF,

Try

oCall := oSkype:SendSms(cPhone, cComment)

Code: Select all

oCall := oSkype:PlaceCall(cphone) 
Regards,
Dutch

Posted: Wed Nov 14, 2007 6:54 pm
by Otto
I would suggest a own forum for the SMS and phone stuff also outlook.
I think this becomes a very important theme in future and it would be easier for someone who starts if all the information is sorted.
At the moment I don’t need this info’s but I know I will need this in near future.

Posted: Fri Nov 16, 2007 11:48 am
by AHF
Can somone who can help me ?
I've tried everything.

Antonio

Posted: Fri Nov 16, 2007 3:14 pm
by richard-service
Hi Antonio,

I think this is you want it.

http://www.fivetech.com.tw/big5/FWH-ActiveX-Skype.html

I use ActiveX to call Skype ActiveX and direct call within contract name or phone number. Runing OK. If you use hardware device PHONE no problem.

Regards,

Richard

Posted: Fri Nov 16, 2007 4:14 pm
by AHF
With Activex I get error but I have the Skyp4com.dll and skype 3 installed. Do you have some clue ?

Antonio

Posted: Fri Nov 16, 2007 9:54 pm
by AHF
I've found the error. Application was forbbiden by skype. It's solved!
Thanks to all.

Antonio

Posted: Fri Nov 16, 2007 10:29 pm
by Antonio Linares
Antonio,

> I've found the error. Application was forbbiden by skype. It's solved!

How did you solve it ? thanks,

Posted: Sat Nov 17, 2007 9:27 am
by AHF
From Skype last version you need to give permission to any program to use skype api. You can do it on :

Tools -> Options -> Advanced

Otherwise all the api requests will be rejected.

It seems next version will return to the way it was before (no permisson necessary) because of the claims.

By the way, the code has the following diference to the one post previously :

oUser:= oSkype:user(cPhone)
oCall := oSkype:PlaceCall(oUser:Handle)


It works perfectly. And it can process a call to a number or if you have the skype user name to a user directly (no cost involved).

In order to avoid any errors the phone number must be in the following format :

"+"country code+phone number without spaces.

If you have "00" in the number it must be taken out.

I'll post the complete code as soon I have it finnished.

Hope this will help.

Antonio

Posted: Sat Nov 17, 2007 9:29 am
by Antonio Linares
Thanks! :-)

Posted: Sat Nov 17, 2007 1:35 pm
by AHF
Below is the code to make phone calls and send sms through skype.
Function Countrycode() not included.

Hope you'll enjoy it. :lol:

Antonio

FUNCTION PhoneTO(cPhone,cNome,cComment,CodeCountry)
Local oSkype,oCall,oUser

DEFAULT CodeCountry := CountryCode()

if empty(cPhone)
return 0
endif

//if its a user do nothing
if val(cPhone) <>0
//phone number build format
cPhone := alltrim(cPhone)
// in the databse all international numbers have 00
//it must be taken out
if substr(cPhone,1,2) == "00"
cPhone := substr(cPhone,3)
else
//all others are national numbers code country must be added
cPhone := CodeCountry+cPhone
endif
cPhone :="+"+cPhone
endif

Try
oSkype := GetActiveObject("Skype4COM.Skype")
Catch
Try
oSkype := CreateObject("Skype4COM.Skype")
Catch
alert("Skype4Com não está instalado!"+;
";"+ole2txterror())
return 0
End
End

If .not. oSkype:Client:IsRunning()
MsgRun("Informação","Activando o Skipe",{||oSkype:Client:Start()})
Endif

//not online
if oSkype:CurrentUserStatus <> oSkype:Convert:TextToUserStatus("ONLINE")
//lets pout it on line
oSkype:changeUserStatus(oSkype:Convert:textToUserStatus("ONLINE"))
endif

Try
oUser:= oSkype:user(cPhone)
oCall := oSkype:PlaceCall(oUser:Handle)
Catch
MsgInfo("Chamada falhada! Telefone: "+cPhone)
return 0
End

oSkype := Nil
RETURN 1

FUNCTION EnviaSms(t_sms,cnome,t_mess,CodeCountry)
Local oSkype,oSMS,oTarget,oChunk,oCall,oUser

DEFAULT CodeCountry := CountryCode()

if empty(t_sms)
return 0
endif

//if its a user do nothing
if val(t_sms) <>0
//phone number build format
t_sms := alltrim(t_sms)
// in the databse all international numbers have 00
//it must be taken out
if substr(t_sms,1,2) == "00"
t_sms := substr(t_sms,3)
else
//all others are national numbers code country must be added
t_sms := CodeCountry+t_sms
endif
t_sms :="+"+t_sms
endif

//format message
t_mess := alltrim(t_mess)
t_mess := strtran(t_mess,"",chr(12)+CHR(13))
t_mess := strtran(t_mess,"",CHR(13))
t_mess := strtran(t_mess,"",chr(26))

Try
oSkype := GetActiveObject("Skype4COM.Skype")
Catch
Try
oSkype := CreateObject("Skype4COM.Skype")
Catch
alert("Skype4Com não está instalado!"+;
";"+ole2txterror())
return 0
End
End

If .not. oSkype:Client:IsRunning()
MsgRun("Informação","Activando o Skip",{||oSkype:Client:Start()})
Endif

//not online
if oSkype:CurrentUserStatus <> oSkype:Convert:TextToUserStatus("ONLINE")
//lets pout it on line
oSkype:changeUserStatus(oSkype:Convert:textToUserStatus("ONLINE"))
endif

Try
oUser:= oSkype:user(t_sms)
oSMS := oSkype:SendSms(oUser:Handle, t_mess) // generic
Catch
msginfo("Não foi possivel enviar o SMS!")
return 0
End

MsgWait( "A aguardar confirmação de envio da sms para: "+t_sms, "Skype SMS", 10 )

If oSms:Status()<>5 // not delivered ?

Msginfo("O envio da SMS pode ter falhado! ")
return 0 // erro SMS

Endif

oSkype := Nil
RETURN 1