sassenach 0 Junior Poster in Training

I have a site which I am working on (www.agilitegear.com).
I already implemented UPS & USPS (domestic only) shipping, but now I have a problem with USPS International shipping.

This is my usps script:

<?php
// This script was written by Mark Sanborn at http://www.marksanborn.net  
// If this script benefits you are your business please consider a donation  
// You can donate at http://www.marksanborn.net/donate.    

function USPS($isInt, $pounds, $ounces, $service, $dest_zip, $country, $length, $width, $height, $stotal, $pobox, $isgift, $long_country) {    
    
    // ========== CHANGE THESE VALUES TO MATCH YOUR OWN ===========
    $userName = '542AGILI4002'; 
    $orig_zip = '50665';
    // =============== DON'T CHANGE BELOW THIS LINE ===============
    /*
    FIRST CLASS
    PRIORITY
    EXPRESS
    BPM
    PARCEL
    MEDIA
    LIBRARY
    ALL
    */

    //NOTES : If First Class is selected, package cannot weigh more than 13 ounces.  
    //NOTES : Maximum USPS package size is 70 pounds 0 ounces.

    $url = "http://production.shippingapis.com/ShippingAPI.dll";  
    $ch = curl_init();  
      
    // set the target url  
    curl_setopt($ch, CURLOPT_URL,$url);  
    curl_setopt($ch, CURLOPT_HEADER, 1);  
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
      
    // parameters to post  
    curl_setopt($ch, CURLOPT_POST, 1);  
    //YF if($service=='FIRST CLASS') { $fctype="<FirstClassMailType>PARCEL</FirstClassMailType>"; }
    //$fctype = ($service=='FIRST CLASS') ? "<FirstClassMailType>PARCEL</FirstClassMailType>":''; 
    $fctype = "<FirstClassMailType>PARCEL</FirstClassMailType>"; 

    //international delivery only
    if($isInt && $country!='US'){
        //<Machinable>false</Machinable>                        
            /*$data = "API=IntlRate&XML=
            <IntlRateRequest USERID=\"$userName\">
                <Package ID=\"1ST\">
                    <Pounds>$pounds</Pounds>
                    <Ounces>$ounces</Ounces>                    
                    <MailType>Package</MailType>
                    <GXG>
                        <Length>$length</Length>
                        <Width>$width</Width>
                        <Height>$height</Height>
                        <POBoxFlag>$pobox</POBoxFlag>
                        <GiftFlag>$isgift</GiftFlag>
                    </GXG>
                    <ValueOfContents>$stotal</ValueOfContents>
                    <Country>$long_country</Country>
                </Package>
            </IntlRateRequest>";*/
            $data = "API=IntlRate&XML=
            <IntlRateRequest USERID=\"$userName\">                
                <Package ID=\"1ST\">
                    <Prohibitions>An issue of a publication in which more than 5 pe<!--1901 skipped-->.</Prohibitions>

                        <Restrictions>The maximum value of a GXG shipment to CANADA is <!--2134 skipped-->.</Restrictions>

                        <Observations>1. Banknotes valued at $100 or more must be put u<!--3374 skipped-->.</Observations>

                        <CustomsForms>First-Class Mail International items and Priority<!--150 skipped-->)</CustomsForms>

                        <ExpressMail>Country Code:CAReciprocal Service Name: There is <!--1281 skipped-->l</ExpressMail>

                        <AreasServed>Please reference Express Mail for Areas Served.</AreasServed>
                    <Service ID=\"1\">
                       <Pounds>4</Pounds>

                        <Ounces>3</Ounces>

                        <MailType>Package</MailType>

                        <Country>JAPAN</Country>

                        <Postage>101.00</Postage>

                        <ValueOfContents>250.00</ValueOfContents>

                        <Insurance>2.00</Insurance>

                        <SvcCommitments>1 - 3 Days</SvcCommitments>

                        <SvcDescription>Global Express Guaranteed (GXG)</SvcDescription>

                        <MaxDimensions>Max. length 46\", width 35\", height 46\" and max. l<!--29 skipped-->\"</MaxDimensions>

                        <MaxWeight>70</MaxWeight>
                    </Service>
                </Package>
            </IntlRateRequest>";  
    } else {
            $data = "API=RateV3&XML=
            <RateV3Request USERID=\"$userName\">
                <Package ID=\"1ST\">
                    <Service>$service</Service>
                    <FirstClassMailType>PARCEL</FirstClassMailType>
                    <ZipOrigination>$orig_zip</ZipOrigination>
                    <ZipDestination>$dest_zip</ZipDestination>
                    <Pounds>$pounds</Pounds>
                    <Ounces>$ounces</Ounces>
                    <Size>REGULAR</Size>
                    <Machinable>TRUE</Machinable>
                </Package>
            </RateV3Request>";  
    }
    // send the POST values to USPS  
    curl_setopt($ch, CURLOPT_POSTFIELDS,$data);  
            
    //echo '<br/><br/>-- '. $data. ' -- <br/>'; // Uncomment to show XML in comments  
    
    $result=curl_exec ($ch);      
    $data = strstr($result, '<?');      
    $xml_parser = xml_parser_create();  
    xml_parse_into_struct($xml_parser, $data, $vals, $index);  
    xml_parser_free($xml_parser);  
    $params = array();  
    $level = array();  
    $rate=0;    
    foreach ($vals as $xml_elem) {                  
        //print_r($xml_elem);
        /*if(isset($xml_elem['tag']) && eregi('error', strtolower($xml_elem['tag']))){            
          echo 'has error, do not proceed<br/>';
        } */
        if(isset($xml_elem['tag']) && eregi('rate', strtolower($xml_elem['tag'])) && isset($xml_elem['value'])){            
            $rate = $xml_elem['value'];
        }
        /*
            if ($xml_elem['type'] == 'open') {  
                if (array_key_exists('attributes',$xml_elem)) {  
                    list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);  
                } else {  
                $level[$xml_elem['level']] = $xml_elem['tag'];  
                }  
            }  
            if ($xml_elem['type'] == 'complete') {  
            $start_level = 1;  
            $php_stmt = '$params';  
            while($start_level < $xml_elem['level']) {  
                $php_stmt .= '[$level['.$start_level.']]';  
                $start_level++;  
            }  
            $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';  
            eval($php_stmt);  
            }  
        */
    }  
    curl_close($ch);  
    //echo '<pre>'; print_r($params); echo'</pre>'; // Uncomment to see xml tags  
    /*
    $i=1;
    while($i < 15) {
	    if($params['RATEV3RESPONSE']['1ST']["$i"]['RATE']=='') { $i++; }
	    else { return $params['RATEV3RESPONSE']['1ST']["$i"]['RATE']; break; }
    }
    */
    return $rate;  
}


?>

i keep on getting an error with $0 value.

Has anyone done this before with USPS international shipping?

thanks in advance.