TrackingURLs – A ColdFusion function to parse Shipping Tracking Numbers

Just a quick post regarding TrackingURLs, a ColdFusion CFC to identify shipping tracking numbers (UPS, USPS, Fedex, OnTrac, DHL, S10) and generate a tracking URL.

Sample Integration

<cfset TrackingURLs = new TrackingURLs()>

<cfset result = TrackingURLs.getTrackingInfo(Form.TrackingNumber)>
<cfif request.isURL(result.url)>
       <cf_newlocation url="#result.url#">
<cfelse>
       <cfoutput>
              <p>Sorry. Tracking number "#EncodeForHTML(Form.TrackingNumber)#" seems invalid.</p>
       </cfoutput>
</cfif>

Enter fullscreen mode Exit fullscreen mode

GitHub Project

JamoCA / TrackingURLs

A ColdFusion CFC to parse & identify ship tracking numbers.

TrackingURLs

A ColdFusion CFC to parse & identify ship tracking numbers.

<cfscript>
TrackingURLs = new TrackingURLs();

cfparam(name="Form.TrackingNumber", default="");

result = TrackingURLs.getTrackingInfo(Form.TrackingNumber);

if (request.isURL(result.url)){
    //location(result.url);
    writedump(result);
} else {
    writeoutput("<p>Sorry. Tracking number "#EncodeForHTML(Form.TrackingNumber)#" seems invalid.</p>");
}

writeOutput("<p>isFedex = #TrackingURLs.isFedex(Form.TrackingNumber)#</p>");

writeOutput("<p>isUSPS = #TrackingURLs.isUSPS(Form.TrackingNumber)#</p>");

writeOutput("<p>isDHL = #TrackingURLs.isDHL(Form.TrackingNumber)#</p>");

writeOutput("<p>isS10 = #TrackingURLs.isS10(Form.TrackingNumber)#</p>");

writeOutput("<p>isOnTrac = #TrackingURLs.isOnTrac(Form.TrackingNumber)#</p>");
</cfscript>

View on GitHub

原文链接:TrackingURLs – A ColdFusion function to parse Shipping Tracking Numbers

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容