Code Samples for The Florist One API

We provide codes samples for the Florist One® API in:

To view full codes samples, an API key is required. Signup for an API key.

The Florist One® API can be accessed from any web based programming language that can use SOAP, XML protocols. If you need code samples in another programming language, please contact us.

Below we provide explanations of our code samples as well as example code for the getProducts() function.

PHP Code Samples

Our PHP codes samples use the NuSOAP SOAP Toolkit for PHP. NuSOAP is a set of PHP classes that allows delevopers to easily consume webs ervices without needing PHP extensions.

Example getProducts() in PHP

			// 1) Get Products Call
			
			        // Input
			        $strSoapUsername = "123456";  //Your API Key
			        $strSoapPassword = "abcd";    //Your API Password
			        $strCategory = "bd";          //Product category 'bd' is for Birthday flowers
			        $intProductCount = "10";      //Nnumber of products to retrieve
			        $intStart = "1";              //Start at the first product
			
			        $this->getProductDetails($strSoapUsername,$strSoapPassword,$strCategory,$intProductCount,$intStart);
			
			        //Get Product Details
			        function getProductDetails($strSoapUsername,$strSoapPassword,$strCategory,$intProductCount,$intStart="")
			        {
				      $blnResult = false;
			
					// Create the client instance
				  $client = new nusoap_client($this->strSoapServer,true);
			
			
			
				  // Check for an error
				      $strErrors = $client->getError();
				      if ($strErrors) {
					if(is_array($strErrors)) {
					    $this->strSoapServerError = implode("\r\n",$strErrors);
					} else {
					    $this->strSoapServerError = $strErrors;
					}
					    //echo("ERORR in Connecting with SOAP server");
					    return $blnResult;
				      }
			
			
				      // Call the SOAP method
			
				  $result = $client->call('getProducts', array("APIKey"=>$strSoapUsername,"APIPassword"=>$strSoapPassword,"category
			"=>$strCategory,"numProducts"=>$intProductCount,"startAt"=>$intStart));
				  // Check for a fault
				  if(count($result['errors']) > 0 ) {
				      $strErrors = null;
				      if(is_array($result['errors'])) {
					    foreach ($result['errors'] as $key=>$strTempError) {
							$strErrors .= $result['errors'][$key]['field']." : ".$result['errors'][$key]['message
			']."\r\n";
						  }
						  $this->strSoapServerError = $strErrors;
					} else {
					    $this->strSoapServerError = $result['errors'];
					}
				  } elseif(count($result['products']) > 0 ) {
				      $arrInput = $result['products'];
				      $arrOurput = array();
				      foreach ($arrInput as $arrTemp ) {
					    $arrOurput[] = array_map("trim",$arrTemp);
			
				      }
				      $this->arrProducts = $arrOurput;
				      unset($arrInput);
				      unset($arrOurput);
				      unset($arrTemp);
				      $blnResult = true;
				  }  elseif($strErrors = $client->getError()) {
			
				      if(is_array($strErrors) && count($strErrors) > 0) {
					$this->strSoapServerError = implode("\r\n",$strErrors);
					} else {
					    $this->strSoapServerError = $strErrors;
					}
			
				  } else {
				      $this->strSoapServerError = $client->response;
				  }
			
				  return $blnResult;
			        }

ASP.NET Code Samples

Our ASP.NET codes samples can be used with any version of Visual Studio (2010 Version 11, 2008 Version 10, 2005 Version 9, 2003 Version 8) and a .NET Framework (Version 4.0 - ASP.NET v4.0, Version 3.5 - ASP.NET v3.5, Version 3.0 - ASP.NET v2.0, Version 2.0 - ASP.NET v2.0). Our code samples should work on .NET Framework Version 1.1 - ASP.NET v1.1 but they have not been tested on this older version.

Example getProducts() in ASP.NET

Java Code Samples

Our Java codes samples use the Axis Soap Engine. We would have liked to have provided Java code samples in Axis 2 and CXF but unfortunately, a yet unresloved bug in the ColdFusion programming language (the language the Florist One® API is written in) does not allow Axis 2 and CXF to be used.

Example getProducts() in Java

import org.apache.axis.AxisFault;
import webservices4.FlowerShopServiceLocator;
import webservices4.result.GetProductsResponse;

public class getProducts {

	/*
	 * Replace these with your own key and password
	 */
	private static final String APIKey      = "your api key";
	private static final String APIPassword = "your api password";


	public static void main(String[] args) throws AxisFault {
		FlowerShopServiceLocator service = new FlowerShopServiceLocator();
		GetProductsResponse response;
		int i;

		try {
			//  Get the the first 10 products in the Everyday category
			response = service.getFlowerShopCfc().getProducts(APIKey, APIPassword, "ao", 10, 1);

			//  If we have errors the web service failed so we need to see what is the reason for the failure
			if( response.getErrors().length > 0 ) {
				for(i=0; i < response.getErrors().length; i++) {
					System.out.println("Error in " + response.getErrors()[i].getField() + " : " + response.getErrors()[i].getMessage());
				}
			} else {
				System.out.println("Numer of products: " + response.getProducts().length);
				for(i=0; i < response.getProducts().length; i++) {
					System.out.println("Product: " + response.getProducts()[i].getCode());
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
		};
	}
}

Coldfusion Code Samples

Our ColdFusion codes samples can be used by ColdFusion 8 and 9.

Example getProducts() in Coldfusion

API Technical Information