Google Client API with PHP – step by step tutorial with (some) screenshots

This page describes how you can access Google data with some handy PHP code, using the official Google Client API for PHP and OAuth2. To make it short, this is not a dirty hack but provides the official way of doing this. Unfortunately the samples provided in the client library by Google might not suite you very well. This script is the foundation for the other Google client API tutorials. Continue reading

Google Client API

This page provides some code for the Google Client API (PHP version), especially with Google Apps for Business accounts. Now it is easy to access information from Google services as Google Analytics or Google Adsense with a PHP script – when interacting with a user but also without e.g. running a cron script.

Available ressources and articles

Related links

OpenEMM – control open source mailing software OpenEMM

About OpenEMM

OpenEMM is a email marketing software for advanced and (semi-) professional users. It is possible to control some functionality also via a webservice interface. So interacting with the software is possible from every programming language that supports webservices. The php class available at this page abstracts the webservice methods and provides a nativ php interface.

More information can be found in the webservice documentation available at http://www.openemm.org/downloads.html. Please setup the webservice interface as written in the documentation first before playing with the OpenEMM php class.

Download and license information

Download OpenEMM php class – Release 1.1 / 4 KB / ZIP-compressed / License: MIT

Release 1.1 fixes minor bugs, it has been tested up to OpenEMM 6.0.1. Feedback is always welcome!

The code is also available at https://github.com/incratec/enarionPhpOpenEMM

Usage of OpenEMM php class

It is easy to interact with the OpenEMM email marketing software via the webservice interface through the OpenEMM php class. For example, the following code displays the information of a subscriber with the subcriber id 6 from the OpenEMM application.

include_once('OpenEMM.class.php');
$openemm = new OpenEMM('openemm.wsdl', 'openemm_user', 'openemm_password');
var_dump($openemm->getSubscriber(6));

This example asumes that the php class file OpenEMM.class.php and the webservice description file openemm.wsdl are located in the same directory as the php script file.

Tipps, tricks and problem solutions

Updating an existing subscriber

Since the webservice interface of OpenEMM does not yet provide an update method for an existing subscriber, a workaround is beeing in the function updateSubscriber used. First, all informatio nof the subscriber are fetched from OpenEMM and then the existing subscriber will be overwritten with a combination of the new values and old values for values, that are not new.

Date format of OpenEMM webservice interface

OpenEMM uses a special date/time format for the webservice interface (see OpenEMM webservice manual, section addSubscriber). To generate this, the function generateDateArray can be used. The first parameter indicates the variable name of the date field, the second param the timestamp in unix format and the 3rd (optional) boolean parameter indicates if the result should also contain time information. This function returns an array containing the date/time information in OpenEMM parameter format. It can be merged with other (e.g. subscriber) values with array_merge.

Example: $openemm->generateDateArray('my_datetime_variable_name', time(), false);

Accessing OpenEMM through a http proxy

Problem: You are running an OpenEMM server in the internet and you would like to access it from your intranet. Between intranet and internet is a http proxy.

Solution: The OpenEMM php class takes an extra argument that is routed directly to PHP when setting up the SOAP connection. There you can setup the http proxy connection settings as described in the PHP documentation.

$soapParameter = array('proxy_host' => "localhost", 'proxy_port' => 8080, 'proxy_login' => "some_name", 'proxy_password' => "some_password");
$openemm = new OpenEMM('openemm.wsdl', 'openemm_user', 'openemm_password', $soapParameter);

Call a Skype user in a html page

Introduction to html-based Skype interaction

When the user has installed Skype, one can open Skype directly from a webpage. The protocol is skype:skypename – and optional flags.

The example will use the chinese demo user of Skype (echo-chinese) – which will record a call and play it back or ping back the typed in chat messages.

Call a skype user

The optional flag is call – to force Skype to call somebody. It can also be left out – but if the user changed the default behaviour to e.g. chat – Skype will open an IM session instead. So – go the save way and use the call – flag.

Example: call a Skype user

call echo-chinese with Skype
<a href="skype:echo-chinese?call">call echo-chinese with Skype</a>

Send an Skype IM message to a Skype user

The optional flag is chat. See the example below to see the usage in a html page.

Example: send a chat message to a Skype user

<a href="skype:echo-chinese?chat">Chat with echo-chinese</a>

Send a voicemail to a Skype user

The optional flag is voicemail – as you might have guessed.

Example: send a voicemail to Skype user

<a href="skype:echo-chinese?voicemail">Send voicemail to echo-chinese</a>

Create a Skype conference call with multiple users

This is as easy as the examples above – just more usernames before the “?” and call as flag.

Example: create a Skype conference call

<a href="skype:echo-chinese;echo123?call">conference call with echo-chinese and echo123</a>

Create a conference chat with multiple users

Same as conference call – with chat as flag.

Example: open a conference chat with multiple users – in html

<a href="skype:echo-chinese;echo123?chat">conference chat with echo-chinese and echo123</a>

Doing a Skype video call with C# / .Net

Introduction and premise

If you’re using ActiveS to control Skype, it’s easy. If not, you should check if you can migrate to ActiveS – which is really recommended! ActiveS is a nice .NET library that supports most of the Skype API – for free (BSD licence – you can even use it for commercial applications).
Skype supports video calls since Skype version 2.0.

Example – doing a Skype video call

With ActiveS it’s easy: you do just a normal call and than switch on the video support:

This example assume’s that m_objAccess is an instance of the SKYPEAPILib.AccessClass which is the ActiveX stub that connects .NET to Skype. skypeId is a string containing the username of the skype user you’re calling. The next to lines enable the sending of video messages (START_VIDEO_SEND) and the receiving of video messages (START_VIDEO_RECEIVE).

Call call = this.m_objAccess.PlaceCall(skypeId); m_objAccess.SendCommand("ALTER CALL " + call.ID + " START_VIDEO_SEND"); m_objAccess.SendCommand("ALTER CALL " + call.ID + " START_VIDEO_RECEIVE");

You can find more information about the video support at the description of the updated Skype protocol – video section

Skype video calls and conference conversations

The Skype conference calls doesn’t support video conversations. Even the Skype window doesn’t support it, the API seems to behave the same.

You can try to do a conference call and than switch on the video support – but it still doesn’t work. So maybe Skype checks the network load and the usage of the video calls – and then maybe enables the conference calls or makes it a payed service. But – nobody knows execept the Skype developer, we’ll see.