Monthly Archives: December 2012

How to send Skype IM programmatically


In this tutorial, we ‘ll see how to send a IM to your Skype friends. For this, you need to access Skype API. There ‘s an Skype ActiveX component which allows to access their API. This is an object oriented layer which wraps the API functinality.

First you need to download the Skype4COM
component. Then You need to create an instance of type COM by specifying the path to above dll.

ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

$skype = new COM('Skype4COM.Skype');

if (!$skype->client()->isRunning()) {
$skype->client()->start(true, true);

$members = new COM('Skype4COM.UserCollection');

$chat = $skype->CreateChatMultiple($members);
$chat->SendMessage("Hi friend");
Leave a comment

Posted by on December 30, 2012 in PHP



PHP SOAP Web Service With NuSOAP


In this tutorial, we create a SOAP web service in PHP.  We use NuSOAP as a third party library for this tutorial. NuSOAP is a very useful library that eases SOAP  web service implementation.

It is a set of PHP classes – no PHP extensions required – that allow developers to create and consume web services based on SOAP 1.1, WSDL 1.1 and HTTP 1.0/1.1.
Download NuSOAP

Copy the lib folder to the project.

We use a simple function that performs zip code loookup as our web service.

First we create SOAP server which exposes the functionality for its clients.



require_once 'lib/nusoap.php';

//Perform client authentication
//Unauthenticated clients are not allowed to access functionality
function doAuthenticate() {
if (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) {

if ($_SERVER['PHP_AUTH_USER'] == "codezone4" && $_SERVER['PHP_AUTH_PW'] == "123")
return true;
return false;

//Retrieve zip code for textual area
//Logic of the web service
function get_zip_code($area) {
//Can query database and any other complex operation
if (!doAuthenticate())
return "Invalid username or password";
if ($area == "Temple Hills") {
return 20757;
} else if ($area == "Cheltenham") {
return 20623;
} else {
return "Can not find zip code for " . $area;

$server = new soap_server();
$server->configureWSDL("zipcodelist", "urn:zipcodelist");

//Register web service function so that clients can access
array("area" => "xsd:string"),
array("return" => "xsd:int"),
"Retrieve zip code for a given area");


Now, run the server. You will see a link to wsdl file. Click that link and view the generated wsdl file. Clients who access the web service needs this wsdl. Save this file with .wsdl extension. You need to specify the URL for wsdl file within client.


$client = new nusoap_client("http://localhost/NuSOAP/zip_codes.wsdl", true);

$error = $client->getError();
if ($error) {
echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
//Use basic authentication method
$client->setCredentials("codezone4", "123", "basic");
$result = "";

if ($client) {
$result = $client->call("get_zip_code", array("area" => "Cheltenham"));
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
echo "</pre>";
} else {
$error = $client->getError();
if ($error) {
echo "<h2>Error</h2><pre>" . $error . "</pre>";
} else {
echo "<h2>zip code</h2><pre>";
echo $result;
echo "</pre>";

echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"

Download Project

Some additional stuff

How to use complex types?

//A complex method
function HelloComplexWorld($mycomplextype)
	return $mycomplextype;

//Create a complex type 
		array( 'ID' => array('name' => 'ID','type' => 'xsd:int'),
				'YourName' => array('name' => 'YourName','type' => 'xsd:string')));

//Register our method using the complex type
// method name:
		// parameter list:
		// return value(s):
		// namespace:
		// soapaction: (use default)
		// style: rpc or document
		// use: encoded or literal
		// description: documentation for the method
		'Complex Hello World Method');

Posted by on December 2, 2012 in PHP


Tags: , ,