RE: [PHP] UPSOnline

From: Date: Sun, 10 Sep 2000 03:53:44 +0000
Subject: RE: [PHP] UPSOnline
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16025@lists.php.net to get a copy of this message
Ben, I'm using PHP4 and it seems that the 4th parameter in fsockopen doesn't exist in some versions of PHP 3 according to the note from scott@mha.ca at http://www.php.net/manual/function.fsockopen.php. Try removing the last parameter from the fsockopen call. Clincy -----Original Message----- From: Ben Weinberger [mailto:ben@digitalsmiths.com] Sent: Saturday, September 09, 2000 8:35 PM To: Clincy Latimer Subject: RE: [PHP] UPSOnline Hi Clincy~ I tried a sample PHP file... I did the following and keep getting an error saying "Warning: Wrong parameter count for fsockopen() in /path/to/my/file/ups.php3 on line 16 -1". Do you know what I'm doing wrong? Thanks, -Ben <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <? function get_ups_amount($svc_type,$zip_from,$zip_to,$country_to,$weight,$is_res,$pick up_type,$pack_type){ $content ="AppVersion=1.2&AcceptUPSLicenseAgreement=YES&ResponseType=application/x-up s-rss&"."ActionCode=3&ServiceLevelCode=".$svc_type."&RateChart=".$pickup_typ e."&ShipperPostalCode=".$zip_from."&ConsigneePostalCode=".$zip_to."&Consigne eCountry=".$country_to."&PackageActualWeight=$weight&ResidentialInd=$is_res& PackagingType=$pack_type"; $content_length = strlen($content); $fp = fsockopen("http://www.ups.com",80,&$error_num,&$err_desc,300); if($fp){ set_socket_blocking($fp,TRUE); fputs($fp, "POST /using/services/rave/qcost_dss.cgi HTTP/1.0\r\n". "content-type: application/x-www-form-urlencoded\r\n". "content-length: $content_length \r\n\r\n". $content); while(!feof($fp)){ $result .= fgets($fp,4096); } fclose($fp); $res_fields = split("\r\n",$result); while(list($key,$value) = each($res_fields)){ if(substr($value,0,9) == 'UPSOnLine'){ $fields = split('%',$value); } } $ret_code = $fields[2]; $ret_msg = $fields[3]; $rate = $fields[12]; } if($ret_code == '0000'){ return $rate; } else { return -1; } } $shipping = get_ups_amount('GND','94105','60616','US','10','1','Regular+Daily+Pickup','0 0'); print "$content"; print "$shipping"; ?> </body> </html>

« previous php.general (#16025) next »