This is the code that I was using for the integration. But it doesn't seem to work. I am not sure if there is something wrong with the code itself.
<?
class fedex
{
var $PostServ ='https://gatewaybeta.fedex.com';
var $PostHost ='https://www.memenethosting.com';
var $Name ='John Doe';
var $CompanyName ='Test Company';
var $CityName ='Test City';
var $StreetAddress ='555 55th St.';
var $PhoneNumber ='5555555';
var $State ='TX';
var $AccountNumber ='55555555';
var $ZipCode ='55555';
var $CountryCode ='US';
function BuildQuery()
{
$this->query_array = array(
0 => "211",
1 => "1st trans",
4003 => $this->Name,
4007 => $this->CompanyName,
4011 => $this->CityName,
4008 => $this->StreetAddress,
4015 => $this->PhoneNumber,
4012 => $this->State,
10 => $this->AccountNumber,
4013 => $this->ZipCode,
4014 => $this->CountryCode,
99 => ""
);
foreach($this->query_array as $key => $val)
{
$this->query .= "$key,\"$val\"";
}
$this->debug[] = array("Generated Query",$this->query);
}
function Post()
{
$this->ch = curl_init();
curl_setopt($this->ch,CURLOPT_URL,"$this->PostServ");
$this->debug[] = array("URL to POST to",$this->PostServ);
curl_setopt($this->ch,CURLOPT_HEADER,1);
curl_setopt($this->ch,CURLOPT_POST,1);
curl_setopt($this->ch,CURLOPT_POSTFIELDS,"?$this->query");
curl_setopt($this->ch,CURLOPT_VERBOSE,1);
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
$len = strlen($this->query);
$custom_header = "POST /GatewayDC HTTP/1.0\nReferer: $this->CompanyName\nHost:$this->PostHost\r\n
Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*\nContent-Type:image/gif\nContent-length:$len\n\n$this->query";
curl_setopt($this->ch,CURLOPT_CUSTOMREQUEST, $custom_header);
$this->result = curl_exec($this->ch);
$this->err_nr =curl_errno($this->ch);
$this->error = curl_error($this->ch);
curl_close($this->ch);
$this->debug[] = array("Query Result",$this->result);
$this->debug[] = array("Query Error",$this->err_nr);
$this->debug[] = array("Error Response",$this->error);
}
function ParseReply()
{
preg_match_all('/([0-9+),"([^"]*)"/',$this->result,$this->result_tmp);
$n = "0";
foreach($this->result_tmp[1] as $val)
{
$this->result_array[$val] = $this->result_tmp[2][$n];
$n++;
}
$this->debug[] = array("Result Array",$this->result_tmp);
$this->debug[] = array("Clean Result Array",$this->result_array);
}
function Go()
{
$this->BuildQuery();
$this->Post();
$this->ParseReply();
return $this->result_array;
}
function Debug()
{
print "<table borde=1>";
foreach($this->debug as $val)
{
print "<tr><td nowrap><b>$val[0]</b></td><td><pre>";
print_r($val[1]);
print "</pre></td></tr>";
}
print "</table>";
}
}
$fedex = new fedex;
$price = $fedex->Go();
$fedex->Debug();
?>
This is the error I get back:
URL to POST to https://gatewaybeta.fedex.com
Query Result
Query Error 52
Error Response Empty reply from server
Result Array Array
(
[0] => Array
(
)
[1] => Array
(
)
)
Clean Result Array
If anyone has done a fedex integration please get a hold of me and help me out. I have been workin on this for quite sometime, but I can't seem to get it right.
ICQ:4718571
Thanks ahead of time,
Sync
FedEx Web Intergration Help
Moderator: General Moderators
Just easier to read no changes
Error Response Empty reply from server
Code: Select all
<?php
class fedex
{
var $PostServ ='https://gatewaybeta.fedex.com';
var $PostHost ='https://www.memenethosting.com';
var $Name ='John Doe';
var $CompanyName ='Test Company';
var $CityName ='Test City';
var $StreetAddress ='555 55th St.';
var $PhoneNumber ='5555555';
var $State ='TX';
var $AccountNumber ='55555555';
var $ZipCode ='55555';
var $CountryCode ='US';
function BuildQuery()
{
$this->query_array = array(
0 => "211",
1 => "1st trans",
4003 => $this->Name,
4007 => $this->CompanyName,
4011 => $this->CityName,
4008 => $this->StreetAddress,
4015 => $this->PhoneNumber,
4012 => $this->State,
10 => $this->AccountNumber,
4013 => $this->ZipCode,
4014 => $this->CountryCode,
99 => ""
);
foreach($this->query_array as $key => $val)
{
$this->query .= "$key,"$val"";
}
$this->debug[] = array("Generated Query",$this->query);
}
function Post()
{
$this->ch = curl_init();
curl_setopt($this->ch,CURLOPT_URL,"$this->PostServ");
$this->debug[] = array("URL to POST to",$this->PostServ);
curl_setopt($this->ch,CURLOPT_HEADER,1);
curl_setopt($this->ch,CURLOPT_POST,1);
curl_setopt($this->ch,CURLOPT_POSTFIELDS,"?$this->query");
curl_setopt($this->ch,CURLOPT_VERBOSE,1);
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
$len = strlen($this->query);
$custom_header = "POST /GatewayDC HTTP/1.0\nReferer: $this->CompanyName\nHost:$this->PostHost\r\n
Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*\nContent-Type:image/gif\nContent-length:$len\n\n$this->query";
curl_setopt($this->ch,CURLOPT_CUSTOMREQUEST, $custom_header);
$this->result = curl_exec($this->ch);
$this->err_nr =curl_errno($this->ch);
$this->error = curl_error($this->ch);
curl_close($this->ch);
$this->debug[] = array("Query Result",$this->result);
$this->debug[] = array("Query Error",$this->err_nr);
$this->debug[] = array("Error Response",$this->error);
}
function ParseReply()
{
preg_match_all('/([0-9+),"([^"]*)"/',$this->result,$this->result_tmp);
$n = "0";
foreach($this->result_tmp[1] as $val)
{
$this->result_array[$val] = $this->result_tmp[2][$n];
$n++;
}
$this->debug[] = array("Result Array",$this->result_tmp);
$this->debug[] = array("Clean Result Array",$this->result_array);
}
function Go()
{
$this->BuildQuery();
$this->Post();
$this->ParseReply();
return $this->result_array;
}
function Debug()
{
print "<table borde=1>";
foreach($this->debug as $val)
{
print "<tr><td nowrap><b>$val[0]</b></td><td><pre>";
print_r($val[1]);
print "</pre></td></tr>";
}
print "</table>";
}
}
$fedex = new fedex;
$price = $fedex->Go();
$fedex->Debug();
?>Code: Select all
<?php
Result Array Array
(
[0] => Array
(
)
[1] => Array
(
)
)
?>Thanks Draco_03
Thank you.
I just hope that someone will be able to help, since I am still stuck on the first little thing on getting the meter number from fedex.
Sync
I just hope that someone will be able to help, since I am still stuck on the first little thing on getting the meter number from fedex.
Sync