Hire A Programmer
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherHire A Programmer

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 5th, 2005, 11:32 AM
artie2005 artie2005 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 artie2005 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 32 m 13 sec
Reputation Power: 0
Fedex Integrations

I am looking to hire someone who has experience in integrating a PHP application with FedEx shipping using a PHP class developed by Jay Powers @Vernmonster.com.

Thanks.

Arturo
aantonio@evaglobalinc.com


Below is a portion of the class code that i am reffering to:

here is the class code:
PHP Code:
 php
-------------------------------------------------------------------------------- 

<?
php 
/* 
$Id: DirectConnect.pm,v 1.17 2003/07/07 13:53:01 jay.powers Exp $ 
Copyright (c) 2003 Vermonster LLC 
All rights reserved. 

This library is free software; you can redistribute it and/or 
modify it under the terms of the GNU Lesser General Public 
License as published by the Free Software Foundation; either 
version 2.1 of the License, or (at your option) any later version. 

This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
Lesser General Public License for more details. 

You should have received a copy of the GNU Lesser General Public 
License along with this library; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 

-------------------------------------------------------------------- 
FedEx-DirectConnect - PHP interface to FedEx Direct Connect API 

This class has been developed to send transactions to FedEx's 
Ship Manager Direct API. It can be used for all transactions 
the API can support. For more detailed information please 
referer to FedEx's documentation located at their website. 
http://www.fedex.com/us/solutions/wis/. Here you will be able 
to download "TagTransGuide.pdf" which outlines all the FedEx 
codes needed to send calls to their API. 

This class requires you have PHP CURL support. 

To submit a transaction to FedEx's Gateway server you must have a valid 
FedEx Account Number and a FedEx Meter Number. To gain access 
and receive a Meter Number you must send a Subscribe () request to 
FedEx containing your FedEx account number and contact information. 

Questions, Comments 

Jay Powers 
jay@vermonster.com 

Vermonster LLC 
312 Stuart St. 
Boston, MA 02116 

*/ 

define('FEDEX_URI''https://gatewaybeta.fedex.com/GatewayDC'true); 
define('FEDEX_HOST''gatewaybeta.fedex.com'true); 
define('REQUEST_REFERER''www.dobius.com'true); 
define('REQUEST_TIMEOUT'10true); 
define('REQUEST_TYPE''CURL'true); 

class 
FedExDC 

var 
$VERSION '0.3'
var 
$NAME 'FedExDC'
var 
$ERROR_STR false

//this will be the field returned by FedEx 
//containing the binary image data 
var $image_key

// FedEx API URI 
var $fedex_uri

// referer host 
var $referer

// set the timeout 
var $timeout

/** 
* load FedEx UTIs => Transaction Types, Applicable Carrier 

* @var FE_TT 
* @access public 
*/ 
var $FE_TT = array ( 
'1002' => array ('007','FDXG'), 
'1005' => array ('023','FDXE'), 
'2016' => array ('021','FDXE'), 
'2017' => array ('022','FDXE'), 
'2018' => array ('019','FDXE'), 
'2024' => array ('025',''), 
'2025' => array ('410',''), 
'3000' => array ('021','FDXG'), 
'3001' => array ('023','FDXG'), 
'3003' => array ('211',''), 
'3004' => array ('022','FDXG'), 
'5000' => array ('402',''), 
'5001' => array ('405',''), 
'5002' => array ('403',''
); 

/** 
* constructor: loads account# and meter# 

* @param int $account FedEx Account number 
* @param int $meter FedEx meter number 
* @param array $params Associative array of parameters listed: 
* fedex_uri: FedEx API URI 
fedex_host: Host for FedEx 
referer: Referering Host 
timeout: Connection timeout in seconds. 

* @access public 
*/ 
function FedExDC ($account$meter=''$params = array()) { 
$this->account $account
$this->meter $meter
$this->time_start $this->getmicrotime(); 

// param defaults 
$this->fedex_uri FEDEX_URI
$this->fedex_host FEDEX_HOST
$this->referer REQUEST_REFERER
$this->timeout REQUEST_TIMEOUT
$this->image_key 188
foreach (
$params as $key => $value) { 
$this->{$key} = $value




/** 
* Sets debug information 

* @param string $string debug data 
* @access private 
*/ 
function debug($string){ 
$this->debug_str .= get_class($this).": $string\n"


/** 
* returns error string if present 

* @return boolean string 
* @access public 
*/ 
function getError(){ 
if(
$this->ERROR_STR!= ""){ 
return 
$this->ERROR_STR

return 
false


/** 
* sets error string 

* @param string $str 
* @access private 
*/ 
function setError($str){ 
$this->ERROR_STR .= $str


/** 
* microtime 

* @return float 
* @access private 
*/ 
function getmicrotime(){ 
list(
$usec$sec) = explode(" ",microtime()); 
return ((float)
$usec + (float)$sec); 


/** 
* creates FedEx buffer string 

* @param int $uti FedEx transaction UTI 
* @param array $vals values to send to FedEx 
* @return string 
* @access public 
*/ 
function setData($uti$vals) { 
$this->sBuf ''
if (empty(
$vals[0])) $vals[0] = $this->FE_TT[$uti][0]; 
if (empty(
$vals[3025])) $vals[3025] = $this->FE_TT[$uti][1]; 
if (isset(
$this->account) and!array_key_exists(10$vals)) $this->sBuf .= '10,"' $this->account '"'
if (isset(
$this->meter) and!array_key_exists(498$vals)) $this->sBuf .= '498,"' .$this->meter'"'
foreach (
$vals as $key => $val) { 
if (
preg_match('/^([0-9]+)\-?[0-9]?$/'$key)) { //let users use the hyphenated number fields 
$this->sBuf .= "$key,\"$val\""
} else { continue; } 

$time $this->getmicrotime() - $this->time_start
$this->debug('setData: build FedEx string ('$time.')'); 
//echo "<br><br>".$this->sBuf."<br><br>"; DEBUG 
return $this->sBuf .= '99,""'


/** 
* parses FedEx return string into assoc array 

* @return array FedEx return values 
* @access public 
*/ 
function _splitData(){ 
$this->rHash = array(); 
$count=0
$st_key 0// start the first key at 0 
$aFedRet preg_split('/,"/s'$this->httpBody); 
foreach (
$aFedRet as $chunk) { 
preg_match('/(.*)"([\d+\-?]+)/s'$chunk$match); 
if (empty(
$match[1])) continue; 
if (
$st_key == 99) continue; 
$this->rHash[$st_key] = $match[1]; 
$st_key $match[2]; //this will be the next key 

$time $this->getmicrotime() - $this->time_start
$this->debug('_splitData: Parse FedEx response ('$time.')'); 
if (
$this->rHash[2]) { 
$this->setError("FedEx Return Error "$this->rHash[2]." : ".$this->rHash[3]); 

return 
$this->rHash


/** 
* decode binary label data 

* @param string $label_file file to save label on disk 
* @return mixed 
* @access public 
*/ 
function label($label_file=false) { 
$this->httpLabel $this->rHash[$this->image_key]; 
if (
$this->httpLabel preg_replace('/%([0-9][0-9])/e'"chr(hexdec($1))"$this->httpLabel)) { 
$this->debug('separate binary image data'); 
$this->debug('decoded binary label data'); 

if (
$label_file) { 
$this->debug('label: trying to write out label to '$label_file); 
$FH fopen ($label_file"w+b"); 
if (!
fwrite($FH$this->httpLabel)) { 
$this->setError("Can't write to file $label_file"); 
return 
false

fclose($FH); 
} else { 
return 
$this->httpLabel



/** 
* prepares and sends request to FedEx API 

* @param string $buf pre-formatted FedEx buffer 
* @return mixed 
* @access public 
*/ 

/** 
* FedEx service availability 

* @param $aData array values to send to FedEx 
* @return string 
* @access private 
*/ 
function service_avail ($aData) { 
$this->setData(2018$aData); 
if (
$aRet $this->transaction()) { 
return 
$aRet
} else { 
$this->setError('unable to process service_avail'); 
return 
false



function 
sig_proof_delivery ($aData) { 
$this->image_key 1471
$this->setData(5001$aData); 
if (
$aRet $this->transaction()) { 
return 
$aRet
} else { 
$this->setError('unable to process sig_proof_delivery'); 
return 
false



/** 
* Track a shipment by tracking number 

* @param $aData array values to send to FedEx 
* @return string 
* @access private 
*/ 
function track ($aData) { 
$this->setData(5000$aData); 
if (
$aRet $this->transaction()) { 
return 
$aRet
} else { 
$this->setError('unable to process track'); 
return 
false



/** 
* Track By Number, Destination, Ship Date, and Reference 

* @param $aData array values to send to FedEx 
* @return string 
* @access private 
*/ 
function ref_track ($aData) { 
$this->setData(5002$aData); 
if (
$aRet $this->transaction()) { 
return 
$aRet
} else { 
$this->setError('unable to process ref_track'); 
return 
false



?> 

Last edited by Sepodati : February 5th, 2005 at 03:28 PM.

Reply With Quote
  #2  
Old February 5th, 2005, 04:24 PM
superprogrammer superprogrammer is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 778 superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 6 Days 14 h 19 m 55 sec
Reputation Power: 6
Send a message via AIM to superprogrammer Send a message via MSN to superprogrammer Send a message via Yahoo to superprogrammer
Please feel free to contact me giving reference to this thread
__________________
Contact info:
Primary email: advanced.programmer@gmail.com
MSN/email: superprg@hotmail.com
AIM: superprg

Reply With Quote
  #3  
Old February 5th, 2005, 08:05 PM
artie2005 artie2005 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 artie2005 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 32 m 13 sec
Reputation Power: 0
Hi Superprogrammer. Check you private message.

Reply With Quote
  #4  
Old February 6th, 2005, 04:15 AM
superprogrammer superprogrammer is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 778 superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 6 Days 14 h 19 m 55 sec
Reputation Power: 6
Send a message via AIM to superprogrammer Send a message via MSN to superprogrammer Send a message via Yahoo to superprogrammer
I have sent you an email
Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherHire A Programmer > Fedex Integrations


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |