Help - Search - Members - Calendar
Full Version: Using PHP with Skype4COM
Skype Community > English > Development, Betas and Skype Garage > Public API
C F Yau_
Hi

I am trying to use Skype4COM with PHP, so I started by trying the CALL.PHP in the Examples.

When I run it, an error shows as below:

PHP Fatal error: Uncaught exception 'com_exception' with message 'Source: Skype4COM.Skype.1
Description: Skype client is not installed.' in call.php:30
Stack trace:
#0 call.php(30): variant->start(true, true)
#1 {main}
thrown in call.php on line 30

(for easy reference, lines 28~30 of call.php is as below:

28 // Start the Skype client, minimized and with no splash screen:
29 if (!$skype->client()->isRunning()) {
30 $skype->client()->start(true, true);
31 }
)

However, my skype client is running properly so I suspect that I may have missed something in my setup. I would be grateful if anyone here would give me a hand on this.

I am using PHP 5.1.3 on WinXP, Skype4COM-1.0.0.21.beta

Thank you!
TheUberOverlord
Is this any help?

http://forum.skype.com/viewtopic.php?p=226912
C F Yau_
Thank you, ZOverLord!

I tried the suggestions in that post but with no luck.

I suspect that it is a problem on my own computer setup.

My Web server is Apache Tomcat. When I start Tomcat as System user, the error messages is as above. No matter Skype.exe is running or not.
When I tried to run Tomcat as Administrator, with Skype.exe not running. I can see Skype.exe was started when I visit call.php, then everything stopped. I'll keep trying to figure out what's happening.

Anyway, thanks again for your help.

By the way, your web site is brilliant!
TheUberOverlord
[quote=C F Yau]Thank you, ZOverLord!

I tried the suggestions in that post but with no luck.

I suspect that it is a problem on my own computer setup.

My Web server is Apache Tomcat. When I start Tomcat as System user, the error messages is as above. No matter Skype.exe is running or not.
When I tried to run Tomcat as Administrator, with Skype.exe not running. I can see Skype.exe was started when I visit call.php, then everything stopped. I'll keep trying to figure out what's happening.

Anyway, thanks again for your help.

By the way, your web site is brilliant![/quote]

Thanks,

I will still also look to see if I can find any better answers about this as well.
adamtrachtenberg
QUOTE(ZOverLord @ Thu Jul 20 2006, 05:37) [snapback]276697[/snapback]

I will still also look to see if I can find any better answers about this as well.


I'm a little late to this party, but did either of you ever figure this out?

I'm running into the exact same issue, but while I know PHP, I'm not a big expert in Windows, COM, or Skype, so it's hard for me know where I should look to start debugging.

-adam
Jaanus
Some comments on it.
Valfa
thi is my code example and ot run correctly!
bye bye
N.B.
In this code I luanch an SIP User Agent called SJPHONE!!!already installed in my PC!

code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
<?php
set_time_limit(NULL);
// Event sink:
class _ISkypeEvents {
var $terminated =false;
var $attached =false;
var $usr=NULL;
var $grp=NULL;

function ApplicationConnecting(&$pApp, &$pUsers)
{
/**/
//echo "Skype2SIP> appl: $pApp utente: $pUsers\n";
}
function ApplicationDatagram(&$pApp, &$pStream, $Text)
{
/**/
}
function ApplicationReceiving(&$pApp, &$pStream)
{
/**/
//echo "Skype2SIP> appl: $pApp stream: $pStream\n";
}
function ApplicationSending(&$pApp, &$pStream)
{
/**/
// echo "Skype2SIP> appl: $pApp stream: $pStream\n";
}
function ApplicationStream(&$pApp, &$pStream)
{
/**/
// echo "Skype2SIP> appl: $pApp stream: $pStream\n";
}
function AttachmentStatus($status)
{
//
if($status == 0)
{
//echo "Skype2SIP> Stato di allacciamento: $status\n";
$this->attached = true;
}
}
function AutoAway($Automatic)
{
/**/
}
function CallDtmfReceived(&$pCall, $code)
{
/**/
}
function CallHistory()
{
/**/
}
function CallStatus($call, $status)
{
if($status == 4) //ringing
{ $cmd1 = sprintf('"C:\Program Files\SJLabs\SJphone\SJPhone.exe" /callto 10.10.25.89+type=sip');
// $handle = popen($cmd1, "r");
echo "Skype2SIP> Chiamata entrante!\nSkype2SIP> Sta squillando..\n";
echo "Skype2SIP> Call $call->id status $status\n";
echo "Skype2SIP> Lancio il mio SIP User Agent..\n";
com_message_pump (6010);
$call->Answer();
}
if($status == 5)
{
echo "Skype2SIP> Chiamata in corso!\n";
if($skype->TCallIoDeviceType == null)
echo 'NULL';
else
echo "Skype2SIP> Input:".$call->TCallIoDeviceType."\n";

}
while($status != 7)
{ //echo $status;
com_message_pump (500);
}
if($status == 7)
{ echo "Skype2SIP> Chiamata terminata!\n";
echo "Skype2SIP> Call $call->id status $status\n";
$cmd2 = sprintf('"C:\Program Files\SJLabs\SJphone\SJPhone.exe" /D');
//exec($cmd2);
//$handle = popen($cmd1, "r");
echo "Skype2SIP> Chiudo la chiamata sul mio SIP User Agent..\n";
echo "Skype2SIP> Resto in ascolto per eventuali chiamate..\n";
}
if($status == cool.png
{ echo "Skype2SIP> Chiamata Persa da parte di $call-> PartnerHandle!\n";
echo "Skype2SIP> Call $call->id status $status\n";
echo "Skype2SIP> Resto in ascolto per eventuali chiamate..\n";
}
}
function Command(&$pCommand)
{
/**/
}
function ConnectionStatus($Status)
{
/**/
//echo "Skype2SIP> conn: $Status\n";
}
function ContactsFocused($UserHandle)
{
/**/
//echo"Skype2SIP> Focus $UserHandle\n";
}
function Error(&$pCommand, $Number, $Description)
{
/**/
}
function GroupDeleted($GroupId)
{
/**/
}
function GroupExpanded(&$pGroup, $Expanded)
{
//echo "Skype2SIP> gruppo espanso: $pGroup val: $Expanded\n";
}
function GroupUsers(&$pGroup, &$pUsers)
{
/*
if($pGroup->Type == $this->convert->TextToGroupType("USERS_WAITING_MY_AUTHORIZATION"))
{ echo "Skype2SIP> Richiesta di autorizzazione in corso!\n Type=".$pGroup->Type."\n";
//$pGroup->Accept();
//if($pGroup!= NULL);
//echo "Nome gruppo".$pGroup->DisplayName."\n";
if($pUsers->Count != 0)
{
echo "Skype2SIP> Numero utenti remoti: ".$pUsers->Count."\n";
if($pUsers->Item($pUsers->Count)!= NULL)
{
echo "Skype2SIP> Nome:".$pUsers->Item($pUsers->Count)->Handle."\n";
$name=$pUsers->Item($pUsers->Count)->FullName ;
$this->usr=$pUsers->Item($pUsers->Count);
$this->gpr=$pGroup;
}
}
}
if($pGroup->Type == $this->convert->TextToGroupType("CUSTOM_GROUP"))
{
echo "Skype2SIP> Custom group!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("ALL_USERS"))
{
echo "Skype2SIP> All Users!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("ALL_FRIENDS"))
{
echo "Skype2SIP> All Friends!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("SKYPE_FRIENDS"))
{
echo "Skype2SIP> Skype Friends!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("SKYPEOUT_FRIENDS"))
{
echo "Skype2SIP> Skype Out Friends!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("ONLINE_FRIENDS"))
{
echo "Skype2SIP> OnLine Friends!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("UNKNOWN_OR_PENDINGAUTH_FRIENDS"))
{
echo "Skype2SIP> Unknow Friends!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("RECENTLY_CONTACTED_USERS"))
{
echo "Skype2SIP> recently Contatc!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("USERS_AUTHORIZED_BY_ME"))
{
echo "Skype2SIP> utente autorizzato da me!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("USERS_BLOCKED_BY_ME"))
{
echo "Skype2SIP> utente bloccato!\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("UNGROUPED_FRIENDS"))
{
echo "Skype2SIP> utente senza gruppo !\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("SHARED_GROUP"))
{
echo "Skype2SIP> utente condiviso !\n Type=".$pGroup->Type."\n";
}
if($pGroup->Type == $this->convert->TextToGroupType("PROPOSED_SHARED_GROUP"))
{
echo "Skype2SIP> proposta di condivisione !\n Type=".$pGroup->Type."\n";
}*/
}

function GroupVisible(&$pGroup, $Visible)
{
/**/
//echo "Skype2SIP> gruppo: $pGroup visibilita': $Visible\n";
}
function MessageHistory($Username)
{
/**/
}
function MessageStatus(&$pMessage, $Status)
{
/**/
//echo "Skype2SIP> Message".$pMessage." status: $Status\n";
}
function Mute($Mute)
{
/**/
}
function OnlineStatus(&$pUsers, $Status)
{
/**/
//echo "Skype2SIP> Users".$pUsers." status: $Status\n";
}
function Reply(&$pCommand)
{
/**/
//echo "Skype2SIP> command: $pCommand\n";

}
function UserStatus($Status)
{
/**/
//echo "Skype2SIP> user status: $Status\n";

}
function VoicemailStatus(&$pMail, $Status)
{
/**/
//echo "Skype2SIP> Mail".$pMail." status: $Status\n";
}
}//_ISkypeEvents

// Create a Skype4COM object:
$skype = new COM("Skype4COM.Skype");
// Create a sink object:
$sink =& new _ISkypeEvents ();
$sink->convert = $skype->convert();
// Connect to the sink:
com_event_sink($skype, $sink, "_ISkypeEvents");
// Create a conversion object:
$convert = $skype->convert;
$convert->language = "en";
print"\n************* <Skype2SIP by CITECVOICE> *************\n\n";
$skype->attach(5,false);
// Start the Skype client, minimized and with no splash screen:
if (!$skype->client()->isRunning())
{
$skype->client()->start(true, true);
print"Skype2SIP> Attendere l'avvio del client Skype";
$i=0;
while($i<7)
{print".";
com_message_pump (1000);
$i++;
}
}
else
print"Skype2SIP> Il Client Skype risulta avviato!";

// If the user status is not "online", change user status to "online":
if ($skype->currentUserStatus() == $convert->textToUserStatus("OFFLINE"))
{
$skype->changeUserStatus($convert->textToUserStatus("ONLINE"));
}
print"\nSkype2SIP> Mi connetto a Skype";
$i=0;
while($i<3)
{print".";
com_message_pump (150);
$i++;
}
print"\n";
//se mi sono interfacciato
if($sink->attached)
{
echo "Skype2SIP> Connessione a Skype riuscita!\n";
$n_c=$skype->Friends->Count;
echo "Skype2SIP> Numero Contatti:".$n_c."\n";

//for($i=1;$i<=$n_c;$i++)
// echo "Contatto(".$i."): ".$skype->Friends->item($i)->handle."\n";
echo "Skype2SIP> Sono in ascolto per eventuali chiamate..\n";
/////////////////// CONTROLLO GRUPPI ///////////////////
/*
* $a=$skype->Groups->item(2)->Users->Count;
echo "nel gruppo All Friends abbiamo ".$a." elementi\n";
for($i=1;$i<=$a;$i++)
echo "Contatto(".$i."): ".$skype->Groups->item(2)->Users->item($i)->handle."\n";

$b=$skype->Groups->item(cool.png->Users->Count;
echo "nel gruppo in attesa abbiamo ".$b." elementi\n";
for($i=1;$i<=$b;$i++)
echo "Contatto(".$i."): ".$skype->Groups->item(cool.png->Users->item($i)->handle."\n";

$c=$skype->Groups->item(6)->Users->Count;
echo "nel gruppo in pending ".$c." elementi\n";
for($i=1;$i<=$c;$i++)
echo "Contatto(".$i."): ".$skype->Groups->item(6)->Users->item($i)->handle."\n";

$d=$skype->Groups->item(3)->Users->Count;
echo "nel gruppo Skype friends abbiamo ".$d." elementi\n";
for($i=1;$i<=$d;$i++)
echo "Contatto(".$i."): ".$skype->Groups->item(3)->Users->item($i)->handle."\n";

$e=$skype->Groups->item(4)->Users->Count;
echo "nel gruppo Skype out abbiamo ".$e." elementi\n";
for($i=1;$i<=$e;$i++)
echo "Contatto(".$i."): ".$skype->Groups->item(4)->Users->item($i)->handle."\n";

$f=$skype->Groups->item(9)->Users->Count;
echo "nel gruppo autorizzati da me ".$f." elementi\n";
for($i=1;$i<=$f;$i++)
echo "Contatto(".$i."): ".$skype->Groups->item(9)->Users->item($i)->handle."\n";
*/
//////////////////////////////////////////////////////////////////
while(!$sink->terminated)
{
com_message_pump (1500);
/*
if (!$skype->client()->isRunning())
{
print"Skype2SIP> Per qualche motivo il Client Skype e' stato chiuso..\n";
print"Skype2SIP> Tento il riavvio del client Skype!\n";
$skype->client()->start(true, true);
}
*/
$skype->ResetCache();
}
}
else
{
echo 'Skype2SIP> La Connessione a Skype non รจ riuscita!';
}
//Sleep:
com_message_pump (3000);
$skype=NULL;
?>

ideogroup
Same problem... answers?
TheUberOverlord
Please see this where, I answered you:

http://forum.skype.com/index.php?showtopic=453691
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.