hide side navigation
    5 most recent
    Web Services
  Flash Spell Checker  Company information and news  LinkToMe  Flash Google MX  Flash Currency Conversion  Language Translation  Flash Server Inspector  Stock Quotes in Flash  Flash 2D and 3D charts
    Library's
    Component's
    Applications
    Articles
The Flash 6 (MX) Player is required to view this area.
Please read over the below text - before downloading the app at the bottom.



Flash MX - Google Web Services API
This application is an example of using Flash MX to communicate with a with a Web Service (Google). By using a combination of the Load Vars Object, Flash MX Components, and a PHP Soap Toolkit - we can easily build applications such as these. Their are lots of applications that this can be used for, from specific Site Search features to spell Checkers. The Google application should prove useful for almost any site - as it offers quite a few features. Hopefully this is just a starting point.

Google Web Service's
This application is more complicated then the previous Web service's we've had up for download on Flash-db (Currency Converter | Language Translator ). The result is sent back as an Array so we have to parse a couple of lines, by looking over the code it should be straight forward.

About
The google Web service's feature that we are concentrating on is an internet search feature. By using the google web service, Flash MX, and PHP with Soap we can build are own version's of Google. All the results will be the same as if you had searched directly from Google.

To Use:
The first thing you will need to do is obtain a License Key and Google Account from: http://www.google.com/apis/ The google license key is required - but only takes a second to obtain and is free. To use this application you will have to enter in your new Google license key in the 'searchGoogle.php' file. Then upload that file, nusoap.php, and the Flash Client to a directory on your web server (or local computer if your running php/apache on it). That should be it. Your server must allow outgoing connections for this to work - Most do, but some large cheap commercial and free hosting companies may restrict this.

To send and recieve Soap based Objects - you will need to use one of the PHP Soap toolkits. We are going to use NuSoap for this example. We are using NuSoap because of it's ease of use, only 1 file, and can be installed on any server/platform at no cost. This is great because we can build and consume Web services with no reliance on propritory software or restrictive licensing agreements. Basically NuSoap is a set of PHP class's that handles everything for you. To use this - we need to specify a couple of items in the client script, including the parameters to be sent, and the method to use. The result's sent back in this case are sent as an Array, theirfore some extra parsing is needed that was not needed in the Currency Converter or Language Translator services. This is a more complicated service so extra care will have to be taken.

The version of Nusoap we are using was choosen because of it's ease of use. The newer version's of Nusoap and the PEAR PHP soap toolkit are more powerful and feature rich solutions - however they require a bit more thought when using.

// This is a shortened version 
// - look over the download for a more complete script.
// ----  License Key Settings ------
$key = 'enter your license Key here';

// Grab Values from Post.
$Query 			= $HTTP_POST_VARS[Query];
$startPage 		= $HTTP_POST_VARS[startPage];

// require nusoap.php
require_once('nusoap.php');

// See if startPage has a value 
//- If not give it a value of 0 - meaning results 0-10.
if ($startPage == "") {
	$start = 0;
} else {
	$start = $startPage;
}

// Parameters to send - 
//by looking over the "Google Developers Kit" 
//you can find more use's then what where doing here.
$parameters = array( 
            'key'         => $key, 
            'q'           => $Query, 
            'start'       => $start, 
            'maxResults'  => 10, 
            'filter'      => false, 
            'restrict'    => '', 
            'safeSearch'  => false, 
            'lr'          => '', 
            'ie'          => '', 
            'oe'          => ''  	
);	

// In this example we are not using a WSDL file,
// instead where using the service's endpoint.
$soapclient = new soapclient('http://api.google.com/search/beta2');

// call the method, send the parameters, and get the results. 
$result = $soapclient->call('doGoogleSearch',$parameters, 'urn:GoogleSearch');

print_r ($result); // This will print out the returned array.  
//In the script included in the download we do the parsing for you.  It's not much.
So when first testing this out - Add the NuSoap.php, the searchGoogle.php (client code), the SWF file and (flash client) - to a directory on your server. And that's about it. After you have verified that the default setup is working - you can then go on to modify the Flash Client as you need. Or experiment with different implementations of this. If you have any questions - be sure to ask away on the Message Board

Important: Nusoap
- For more info you can visit:
http://dietrich.ganx4.com/nusoap/

You can also check out the newest CVS version of Nusoap on sourceforge at: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/nusoap/lib/ (although when first starting it will be much easier to simply use the 1 nusoap.php file).

About NuSoap:
NuSOAP is a rewrite of SOAPx4, provided by NuSphere. NuSOAP is a group of PHP classes that allow developers to create and consume SOAP web services. It does not require any special PHP extensions, which makes it usable by all PHP developers, regardless of ISP, server or platform.

Nusoap proves development of PHP web services as an alternative to .net and J2EE. (as if we needed any convincing!!)..

If you are interested in a version of this Soap toolkit that has some extra functionality I would recommend:
http://pear.php.net/package-info.php?pacid=87

The PEAR Soap Toolkit - may be a bit harder to use at first (which is the reason I'm using Nusoap for this example) but you will find some added features - that and it's updated much much more often.

Extra big Thanks to:
*** Dietrich Ayala *** - For NuSoap (which is also the base for part of the Pear/CVS version)!!!
*** Shane Caraveo *** For working on the PEAR and CVS versions of SOAP for PHP!!!!

Download Example Files Click here

Please keep a logo or text link back to Flash-db on the Flash client (for commercial and non-testing implementations)

If you have any trouble with the Flash or PHP side - be sure to visit the message boards at Flash-db Message Boards. Some of the functions for changing the style's of components and change handlers may be a bit confusing on the Flash side of things.

Flash Client Author: Jeff Hill