Introduction to Zend Framework

 Learning Zend Framework

appendix

 Zend Framework Reference


  •  Zend_Gdata
  •  Zend_Http
  •  Zend_InfoCard
  •  Zend_Json
  •  Zend_Layout
  •  Zend_Ldap
  •  Zend_Loader
  •  Zend_Locale
  •  Zend_Log
  •  Zend_Mail
  •  Zend_Markup
  •  Zend_Measure
  •  Zend_Memory
  •  Zend_Mime
  •  Zend_Navigation
  •  Zend_Oauth
  •  Zend_OpenId
  •  Zend_Paginator
  •  Zend_Pdf
  •  Zend_ProgressBar
  •  Zend_Queue
  •  Zend_Reflection
  •  Zend_Registry
  •  Zend_Rest

  •  Zend_Search_Lucene
  •  Zend_Serializer
  •  Zend_Server
  •  Zend_Service
  •  Zend_Session
  •  Zend_Soap
  •  Zend_Tag
  •  Zend_Test
  •  Zend_Text
  •  Zend_TimeSync
  •  Zend_Tool
  •  Zend_Tool_Framework
  •  Zend_Tool_Project
  •  Zend_Translate
  •  Zend_Uri
  •  Zend_Validate
  •  Zend_Version
  •  Zend_View
  •  Zend_Wildfire
  •  Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Update 2011-11-16 - Revision 24438 - Version ZF 1.11.x

    63.30. Zend_Service_StrikeIron: Bundled Services

    Zend_Service_StrikeIron comes with wrapper classes for three popular StrikeIron services.

    63.30.1. ZIP Code Information

    Zend_Service_StrikeIron_ZipCodeInfo provides a client for StrikeIron's Zip Code Information Service. For more information on this service, visit these StrikeIron resources:

    The service contains a getZipCode() method that will retrieve information about a United States ZIP code or Canadian postal code:

    $strikeIron = new Zend_Service_StrikeIron(array('username' => 'your-username',
                                                    
    'password' => 'your-password'));

    // Get a client for the Zip Code Information service
    $zipInfo $strikeIron->getService(array('class' => 'ZipCodeInfo'));

    // Get the Zip information for 95014
    $response $zipInfo->getZipCode(array('ZipCode' => 95014));
    $zips $response->serviceResult;

    // Display the results
    if ($zips->count == 0) {
        echo 
    'No results found';
    } else {
        
    // a result with one single zip code is returned as an object,
        // not an array with one element as one might expect.
        
    if (! is_array($zips->zipCodes)) {
            
    $zips->zipCodes = array($zips->zipCodes);
        }

        
    // print all of the possible results
        
    foreach ($zips->zipCodes as $z) {
            
    $info $z->zipCodeInfo;

            
    // show all properties
            
    print_r($info);

            
    // or just the city name
            
    echo $info->preferredCityName;
        }
    }

    // Detailed status information
    // http://www.strikeiron.com/exampledata/StrikeIronZipCodeInformation_v3.pdf
    $status $response->serviceStatus;

    63.30.2. U.S. Address Verification

    Zend_Service_StrikeIron_USAddressVerification provides a client for StrikeIron's U.S. Address Verification Service. For more information on this service, visit these StrikeIron resources:

    The service contains a verifyAddressUSA() method that will verify an address in the United States:

    $strikeIron = new Zend_Service_StrikeIron(array('username' => 'your-username',
                                                    
    'password' => 'your-password'));

    // Get a client for the Zip Code Information service
    $verifier $strikeIron->getService(array('class' => 'USAddressVerification'));

    // Address to verify. Not all fields are required but
    // supply as many as possible for the best results.
    $address = array('firm'           => 'Zend Technologies',
                     
    'addressLine1'   => '19200 Stevens Creek Blvd',
                     
    'addressLine2'   => '',
                     
    'city_state_zip' => 'Cupertino CA 95014');

    // Verify the address
    $result $verifier->verifyAddressUSA($address);

    // Display the results
    if ($result->addressErrorNumber != 0) {
        echo 
    $result->addressErrorNumber;
        echo 
    $result->addressErrorMessage;
    } else {
        
    // show all properties
        
    print_r($result);

        
    // or just the firm name
        
    echo $result->firm;

        
    // valid address?
        
    $valid = ($result->valid == 'VALID');
    }

    63.30.3. Sales & Use Tax Basic

    Zend_Service_StrikeIron_SalesUseTaxBasic provides a client for StrikeIron's Sales & Use Tax Basic service. For more information on this service, visit these StrikeIron resources:

    The service contains two methods, getTaxRateUSA() and getTaxRateCanada(), that will retrieve sales and use tax data for the United States and Canada, respectively.

    $strikeIron = new Zend_Service_StrikeIron(array('username' => 'your-username',
                                                    
    'password' => 'your-password'));

    // Get a client for the Sales & Use Tax Basic service
    $taxBasic $strikeIron->getService(array('class' => 'SalesUseTaxBasic'));

    // Query tax rate for Ontario, Canada
    $rateInfo $taxBasic->getTaxRateCanada(array('province' => 'foo'));
    print_r($rateInfo);               // show all properties
    echo $rateInfo->GST;              // or just the GST (Goods & Services Tax)

    // Query tax rate for Cupertino, CA USA
    $rateInfo $taxBasic->getTaxRateUS(array('zip_code' => 95014));
    print_r($rateInfo);               // show all properties
    echo $rateInfo->state_sales_tax;  // or just the state sales tax
    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...