<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Algirdas Varnagiris &#187; PHP</title>
	<atom:link href="http://www.varnagiris.net/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.varnagiris.net</link>
	<description>The cyber-place where I live</description>
	<lastBuildDate>Thu, 18 Feb 2010 17:19:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to compare text and mark differences using PHP</title>
		<link>http://www.varnagiris.net/2009/04/12/how-to-compare-text-and-mark-differences-using-php/</link>
		<comments>http://www.varnagiris.net/2009/04/12/how-to-compare-text-and-mark-differences-using-php/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 08:09:27 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/?p=117</guid>
		<description><![CDATA[I was looking for a simple class which will compare to strings and return a result with marked differences. What chars or words where removed and which were added. Just like wiki compare revisions. Actually i googled a lot and finally found a result: The main class which do mostly all the job is Text_Diff, [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple class which will compare to strings and return a result with marked differences. What chars or words where removed and which were added. Just like wiki compare revisions. Actually i googled a lot and finally found a result:<br />
The main class which do mostly all the job is Text_Diff, you can download it from <a href="http://pear.php.net/package/Text_Diff/">http://pear.php.net/package/Text_Diff/</a></p>
<p>The other tool I used was <a href="http://software.zuavra.net/inline-diff/">http://software.zuavra.net/inline-diff/</a>. It use Text_Diff and render results.<br />
If you have two strings: &#8220;my blue pen&#8221; and &#8220;my red pen&#8221;, this is the diff and it will produce: &#8220;my &lt;del&gt;blue&lt;/del&gt;&lt;ins&gt;red&lt;/ins&gt; pen&#8221;.<span id="more-117"></span><br />
It does the following:</p>
<ul>
<li>takes two strings</li>
<li>splits each of them into arrays containing one character per entry</li>
<li>considers the two arrays to be &#8220;lines&#8221; and uses Text_Diff from PEAR to compute a diff</li>
<li>it uses my own diff renderer which extends the one from Text_Diff and renders the differences &#8220;inline&#8221; using &lt;del&gt;&lt;/del&gt; and &lt;ins&gt;&lt;/ins&gt; to mark them. These tags are customizable.</li>
<li>finally, it returns the string consisting of the two originals mashed together, with the inline diffs applied.</li>
</ul>
<p>Result example:<br />
If you have two strings: &#8220;my blue pen&#8221; and &#8220;my red pen&#8221;, this is the diff and it will produce: &#8220;my <del>blue</del><ins>red</ins> pen&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2009/04/12/how-to-compare-text-and-mark-differences-using-php/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Ajax feedback form using jQuery &amp; Boxy plugin</title>
		<link>http://www.varnagiris.net/2009/04/11/ajax-feedback-form-using-jquery-boxy-plugin/</link>
		<comments>http://www.varnagiris.net/2009/04/11/ajax-feedback-form-using-jquery-boxy-plugin/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 06:50:54 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[java script]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/?p=102</guid>
		<description><![CDATA[I really enjoy jQuery and its capabilities. It is more lightweight than Prototype and it can do the same or even more. Also this library has lots of plugins and one of them is Boxy. Boxy is a flexible, Facebook-style dialog box for jQuery with support for dragging and size tweening. It differs from other [...]]]></description>
			<content:encoded><![CDATA[<p>I really enjoy <a href="http://jquery.com/">jQuery</a> and its capabilities. It is more lightweight than Prototype and it can do the same or even more. Also this library has lots of plugins and one of them is <a href="http://plugins.jquery.com/project/boxy">Boxy</a>. Boxy is a flexible, Facebook-style dialog box for <a href="http://jquery.com/">jQuery</a> with support for dragging and size tweening. It differs from other overlays I&#8217;ve seen by providing an object interface to control dialogs after they&#8217;ve been created. And for simple usage scenarios, boxy also provides a <a href="http://plugins.jquery.com/">jQuery plugin</a> for automatically hooking up links and forms, as well as an ask() helper for presenting multiple choices to the user.</p>
<p>Here&#8217;s an example, taken from feedback (contact us) form:<br />
<img class="aligncenter size-full wp-image-103" title="example" src="http://www.varnagiris.net/wp-content/uploads/2009/04/example.png" alt="example" width="362" height="333" /><span id="more-102"></span></p>
<p>Lets start coding. First of all, we need to have a link. When we click it, it will create boxy window.<br />
<code>&lt;a href="#" class="contact_us"&gt;Contact us&lt;/a&gt;</code></p>
<p>Short javascript which do everything: handle contact us link click, creates boxy window, handle form submit, post form using ajax and set the respond to boxy content.</p>
<pre><code>
$(function() {
    /* set global variable for boxy window */
    var contactBoxy = null;
    /* what to do when click on contact us link */
    $('.contact_us').click(function(){
        var boxy_content;
        boxy_content += "&lt;div style=\"width:300px; height:300px\"&gt;&lt;form id=\"feedback\"&gt;";
        boxy_content += "&lt;p&gt;Subject&lt;br /&gt;&lt;input type=\"text\" name=\"subject\" id=\"subject\" size=\"41\" /&gt;&lt;/p&gt;&lt;p&gt;Your name and/or email:&lt;br /&gt;&lt;input type=\"text\" name=\"your_email\" size=\"41\" /&gt;&lt;/p&gt;&lt;p&gt;Comment:&lt;br /&gt;&lt;textarea name=\"comment\" id=\"comment\" cols=\"39\" rows=\"5\"&gt;&lt;/textarea&gt;&lt;/p&gt;&lt;br /&gt;&lt;input type=\"submit\" name=\"submit\" value=\"Send &gt;&gt;\" /&gt;";
        boxy_content += "&lt;/form&gt;&lt;/div&gt;";
        contactBoxy = new Boxy(boxy_content, {
            title: "Send feedback",
            draggable: false,
            modal: true,
            behaviours: function(c) {
                c.find('#feedback').submit(function() {
                    Boxy.get(this).setContent("&lt;div style=\"width: 300px; height: 300px\"&gt;Sending...&lt;/div&gt;");
                    // submit form by ajax using post and send 3 values: subject, your_email, comment
                    $.post("feedback.php", { subject: c.find("input[name='subject']").val(), your_email: c.find("input[name='your_email']").val(), comment: c.find("#comment").val()},
                    function(data){
                        /*set boxy content to data from ajax call back*/
                        contactBoxy.setContent("&lt;div style=\"width: 300px; height: 300px\"&gt;"+data+"&lt;/div&gt;");
                    });
                    return false;
                });
            }
        });
        return false;
    });
});
</code></pre>
<p>So thats all. I believe you will be able to create feedback.php your self. And <a href="http://www.varnagiris.net/wp-content/examples/boxy_feedback/">here is the live demo</a> of this feedback (a.k.a contact us) form</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2009/04/11/ajax-feedback-form-using-jquery-boxy-plugin/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Change content using AJAX with FadeIn FadeOut effect</title>
		<link>http://www.varnagiris.net/2009/02/26/change-content-using-ajax-with-fadein-fadeout-effect/</link>
		<comments>http://www.varnagiris.net/2009/02/26/change-content-using-ajax-with-fadein-fadeout-effect/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 16:34:38 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[fade]]></category>
		<category><![CDATA[java script]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/?p=60</guid>
		<description><![CDATA[Here you will find how to do such a trick: when somebody clicks the button, the old content fades out and then the new fades in. To do this I used jQuery witch is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. [...]]]></description>
			<content:encoded><![CDATA[<p>Here you will find how to do such a trick: when somebody clicks the button, the old content fades out and then the new fades in.<br />
To do this I used <a href="http://jquery.com/">jQuery</a> witch is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.<br />
<span id="more-60"></span><br />
The java script code is quite short and easy:</p>
<pre>
<code>
function refreshContent() {
  $("#content").fadeOut("slow", function(){
    $("#content").load("getrandomcontent.php",false, function() {
      $("#content").fadeIn("slow");
    });
  })
  return false;
}
</code>
</pre>
<p>Now you can use this function for a link<br />
<code>&lt;a href="#" onclick="return refreshContent();"&gt;Refresh&lt;/a&gt;</code><br />
When you click it, the content in <strong>div</strong> element with an id <em>&#8220;content&#8221;</em> will be changed. getrandomcontent.php is used to get random content.</p>
<p><a href="http://www.varnagiris.net/wp-content/examples/ajax_fade/">Check our demo</a>.</p>
<p><em>If this post helped you to solve your problem, please donate me. Donation button can be found on the right side of the page.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2009/02/26/change-content-using-ajax-with-fadein-fadeout-effect/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Moving MySQL data from 4.0 to 5.x</title>
		<link>http://www.varnagiris.net/2007/12/03/moving-mysql-data-from-40-to-5x/</link>
		<comments>http://www.varnagiris.net/2007/12/03/moving-mysql-data-from-40-to-5x/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 13:24:55 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/2007/12/03/moving-mysql-data-from-40-to-5x/</guid>
		<description><![CDATA[I needed to move data from one database to another. The source DB was MySQL 4.0 and the destination was MySQL 5.1. And all the problems was with UTF-8 symbols. I couldn&#8217;t get it to work on MySQL 5.1. I search on the internet and figured out that MySQL 4.0 does not support UTF-8 and [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to move data from one database to another. The source DB was MySQL 4.0 and the destination was MySQL 5.1. And all the problems was with UTF-8 symbols. I couldn&#8217;t get it to work on MySQL 5.1. I search on the internet and figured out that MySQL 4.0 does not support UTF-8 and it is supported only from MySQL 4.1.<br />
You can store UTF-8 date on MySQL 4.0 but it&#8217;s not encoded using UTF-8. The data is encoded using the default encoding &#8216;Latin1&#8242;, so the only thing what you need is to make an export file and upload using PhpMyAdmin, but don&#8217;t forget to select that the data is encoded &#8216;Latin1&#8242; and not UTF-8.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2007/12/03/moving-mysql-data-from-40-to-5x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another FedEx class update</title>
		<link>http://www.varnagiris.net/2007/09/28/another-fedex-class-update/</link>
		<comments>http://www.varnagiris.net/2007/09/28/another-fedex-class-update/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 20:09:39 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[FedEx]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/2007/09/28/another-fedex-class-update/</guid>
		<description><![CDATA[FedEx supports only 150 pound per package, so if you are trying to calculate rates for package which weight more than 150 you get an error. The fix was made and now PackageCount is automatically counted by given weight. You can download updated FedEx class from this post.]]></description>
			<content:encoded><![CDATA[<p>FedEx supports only 150 pound per package, so if you are trying to calculate rates for package which weight more than 150 you get an error. The fix was made and now PackageCount is automatically counted by given weight.</p>
<p>You can download updated FedEx class from this <a href="http://www.varnagiris.net/2006/06/01/php-fedex-shipping-rates-calculator/">post</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2007/09/28/another-fedex-class-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: FedEx shipping rates calculator updated</title>
		<link>http://www.varnagiris.net/2007/08/31/php-fedex-shipping-rates-calculator-updated/</link>
		<comments>http://www.varnagiris.net/2007/08/31/php-fedex-shipping-rates-calculator-updated/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 10:22:56 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[FedEx]]></category>
		<category><![CDATA[rates]]></category>
		<category><![CDATA[shipping]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/2007/08/31/php-fedex-shipping-rates-calculator-updated/</guid>
		<description><![CDATA[One user was using my FedEx class and could not get rates for Ground service. I have just figured out what was the problem. First of all Ground and Home delivery are ground services and you must set Carrier code to FDXG. $fedex->setCarrierCode("FDXG"); After this I found few bugs witch I fixed and now you [...]]]></description>
			<content:encoded><![CDATA[<p>One user was using my FedEx class and could not get rates for Ground service. I have just figured out what was the problem. First of all Ground and Home delivery are ground services and you must set Carrier code to FDXG.</p>
<pre><code>$fedex->setCarrierCode("FDXG");</code></pre>
<p>After this I found few bugs witch I fixed and now you can download updated FedEx class from <a href="http://www.varnagiris.net/2006/06/01/php-fedex-shipping-rates-calculator/">this post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2007/08/31/php-fedex-shipping-rates-calculator-updated/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP: FedEx shipping rates calculator</title>
		<link>http://www.varnagiris.net/2006/06/01/php-fedex-shipping-rates-calculator/</link>
		<comments>http://www.varnagiris.net/2006/06/01/php-fedex-shipping-rates-calculator/#comments</comments>
		<pubDate>Thu, 01 Jun 2006 06:49:38 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[FedEx]]></category>
		<category><![CDATA[rates]]></category>
		<category><![CDATA[shipping]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/2006/06/01/php-fedex-shipping-rates-calculator/</guid>
		<description><![CDATA[FedEx Ship Manager (FSM) Direct was designed to allow customers to connect directly to the FedEx back end systems using their own communications protocol. Welcome to FSM Direct! You can compose FedEx XML Transactions to interface between your e-commerce application and the FedEx server and vice versa. This solution is applicable only to those customers [...]]]></description>
			<content:encoded><![CDATA[<p><strong>FedEx</strong> Ship Manager (FSM) Direct was designed to allow customers to connect directly to the FedEx back end systems using their own communications protocol. Welcome to FSM Direct!<br />
You can compose FedEx XML Transactions to interface between your <strong>e-commerce</strong> application and the FedEx server and vice versa.<br />
This solution is applicable only to those customers that have the development resources and knowledge to develop their own FedEx interface.</p>
<p><em>Before you begin:</em><br />
FSM Direct Site Registration: To register in the FSM Direct program, go to <a href="http://www.fedex.com/us/solutions/wis/">http://www.fedex.com/us/solutions/wis/</a>. Register and complete the brief registration form.</p>
<p>Steps for developing your own communications protocol and integrating it into your application are listed below.</p>
<ul>
<li>Read and accept the FedEx Ship Manager Direct license agreement.</li>
<li>Review the FedEx Direct Documentation: Determine if this alternative or FedEx API is appropriate for your application.</li>
<li>Develop your application.</li>
<li>Send an email to websupport@fedex.com. Request to be set up for testing. Attach FedEx Express and/or FedEx Ground account number(s).</li>
<li>Test your application.</li>
</ul>
<p>All documentation can be found here:</p>
<p>http://www.fedex.com/us/solutions/wis/pdf/fsm_directmanual.pdf</p>
<p>http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf</p>
<p>Here&#8217;s more about this class<br />
<span id="more-36"></span></p>
<p>How to use this Fedex rates class:</p>
<pre>
<code>
    $fedex = new Fedex;
    $fedex->setServer("https://gatewaybeta.fedex.com/GatewayDC");
    $fedex->setAccountNumber(123123123);
    $fedex->setMeterNumber(12312312);
    $fedex->setCarrierCode("FDXE");
    $fedex->setDropoffType("REGULARPICKUP");
    $fedex->setService($service, $serviceName);
    $fedex->setPackaging("YOURPACKAGING");
    $fedex->setWeightUnits("LBS");
    $fedex->setWeight(17);
    $fedex->setOriginStateOrProvinceCode("OH");
    $fedex->setOriginPostalCode(44333);
    $fedex->setOriginCountryCode("US");
    $fedex->setDestStateOrProvinceCode("CA");
    $fedex->setDestPostalCode(90210);
    $fedex->setDestCountryCode("US");
    $fedex->setPayorType("SENDER");

    $price = $fedex->getPrice();
</code></pre>
<p>All available variables can be found here: http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf (FDXRateRequest)</p>
<p>Possible Fedex answer:</p>
<pre>
<code>
fedex Object
(
    [server] => https://gatewaybeta.fedex.com/GatewayDC
    [accountNumber] => 123123123
    [meterNumber] => 12312312
    [carrierCode] => FDXE
    [dropoffType] => REGULARPICKUP
    [service] => STANDARDOVERNIGHT
    [serviceName] => FedEx Standard Overnight
    [packaging] => YOURPACKAGING
    [weightUnits] => LBS
    [weight] => 17
    [originStateOrProvinceCode] => OH
    [originPostalCode] => 44333
    [originCountryCode] => US
    [destStateOrProvinceCode] => CA
    [destPostalCode] => 90210
    [destCountryCode] => US
    [payorType] => SENDER
    [price] => price Object
        (
            [service] => FedEx Standard Overnight
            [rate] => 86.37
            [response] => Array
                (
                  ...//Here is full xml response
                )
        )
)
</code>
</pre>
<p><a id="p37" href="http://www.varnagiris.net/wp-content/uploads/2006/06/Fedex.zip" title="Fedex rates" onclick="javascript: pageTracker._trackPageview('/downloads/FedEx');">Click here to download FedEx shipping rates calculator class</a></p>
<p>Please make a donation of <strong>1$</strong> if you find our software useful and want to support the continued development.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="algirdas@varnagiris.net"/>
<input type="hidden" name="item_name" value="FedEx Rates Class"/>
<input type="hidden" name="amount" value="1.00"/>
<input type="hidden" name="buyer_credit_promo_code" value=""/>
<input type="hidden" name="buyer_credit_product_category" value=""/>
<input type="hidden" name="buyer_credit_shipping_method" value=""/>
<input type="hidden" name="buyer_credit_user_address_change" value=""/>
<input type="hidden" name="no_shipping" value="0"/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="tax" value="0"/>
<input type="hidden" name="lc" value="US"/>
<input type="hidden" name="bn" value="PP-DonationsBF"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px" onclick="javascript: pageTracker._trackPageview('/goal/donate.html');" />
<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" style="border:0px" /><br />
</form>
<p>Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2006/06/01/php-fedex-shipping-rates-calculator/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>PHP: USPS rates calculator</title>
		<link>http://www.varnagiris.net/2006/05/04/php-usps-rates-calculator/</link>
		<comments>http://www.varnagiris.net/2006/05/04/php-usps-rates-calculator/#comments</comments>
		<pubDate>Thu, 04 May 2006 14:10:02 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[rates]]></category>
		<category><![CDATA[USPS]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/2006/05/04/php-usps-rates-calculator/</guid>
		<description><![CDATA[The USPS Web Tools allow developers of web-based and shrink-wrapped applications access to the on-line services of the United States Postal Service (USPS). They provide easy access to shipping information and services for your customers. Your customers can utilize the functions provided by the USPS without ever leaving your web site. Once the Web Tools [...]]]></description>
			<content:encoded><![CDATA[<p>The USPS Web Tools allow developers of web-based and shrink-wrapped applications access to the on-line services of the United States Postal Service (USPS).  They provide easy access to shipping information and services for your customers. Your customers can utilize the functions provided by the USPS without ever leaving your web site.  Once the Web Tools are integrated, your server communicates through the USPS Web Tools server over HTTP using XML (eXtensible Markup Language).</p>
<p> <strong>Rates Calculators</strong></p>
<p> Everything in details can be found here:<br />
 <a href="http://www.usps.com/webtools/rate.htm">http://www.usps.com/webtools/rate.htm</a></p>
<p> First steps:</p>
<ol>
<li>Register online (You will get your own user name)</li>
<li>Test this script (You can use only test data)</li>
<li>Contact ICCC and go live.</li>
</ol>
<p>    When you have completed your testing, email the USPS Internet Customer Care  Center (ICCC).  They will switch your profile to allow you access to the  production server and will provide you with the production URL.<span id="more-34"></span></p>
<p>    <strong>Domestic and International Rates</strong></p>
<p>    <em>Domestic rates</em></p>
<p>    Test 1:</p>
<pre>
<code>
    $usps = new USPS;
    $usps->setServer("http://testing.shippingapis.com/ShippingAPITest.dll");
    $usps->setUserName("?????????");
    $usps->setService("PRIORITY");
    $usps->setDestZip("20008");
    $usps->setOrigZip("10022");
    $usps->setWeight(10, 5);
    $usps->setContainer("Flat Rate Box");
    $usps->setCountry("USA");
    $price = $usps->getPrice();
</code>
</pre>
<p>    Response 1:</p>
<pre>
<code>
    usps Object
    (
        [server] => http://testing.shippingapis.com/ShippingAPITest.dll
        [user] => ???????????
        [pass] =>
        [service] => PRIORITY
        [dest_zip] => 20008
        [orig_zip] => 10022
        [pounds] => 10
        [ounces] => 5
        [container] => Flat Rate Box
        [size] => REGULAR
        [machinable] =>
        [country] => USA
        [zone] => 3
        [list] => Array
            (
                [0] => price Object
                    (
                        [mailservice] => "Priority Mail Flat Rate Box (11.25'' x 8.75'' x 6'')"
                        [rate] => 7.70
                    )
                [1] => price Object
                    (
                        [mailservice] => "Priority Mail Flat Rate Box (14''x 12'' x 3.5'')"
                        [rate] => 7.70
                    )
            )
    )
</code>
</pre>
<p>    Test 2:</p>
<pre>
<code>
    $usps = new USPS;
    $usps->setServer("http://testing.shippingapis.com/ShippingAPITest.dll");
    $usps->setUserName("?????????");
    $usps->setService("All");
    $usps->setDestZip("20008");
    $usps->setOrigZip("10022");
    $usps->setWeight(10, 5);
    $usps->setContainer("Flat Rate Box");
    $usps->setCountry("USA");
    $usps->setMachinable("true");
    $usps->setSize("LARGE");
    $price = $usps->getPrice();
</code>
</pre>
<p>    Response 2:</p>
<pre>
<code>
    usps Object
    (
        [server] => http://testing.shippingapis.com/ShippingAPITest.dll
        [user] => ???????????
        [pass] =>
        [service] => All
        [dest_zip] => 20008
        [orig_zip] => 10022
        [pounds] => 10
        [ounces] => 5
        [container] => Flat Rate Box
        [size] => LARGE
        [machinable] => true
        [country] => USA
        [zone] => 3
        [list] => Array
            (
                [0] => price Object
                    (
                        [mailservice] => "Express Mail to PO Addressee"
                        [rate] => 39.20
                    )
                [1] => price Object
                    (
                        [mailservice] => "Priority Mail"
                        [rate] => 8.95
                    )
                [2] => price Object
                    (
                        [mailservice] => "Parcel Post"
                        [rate] => 7.80
                    )
                [3] => price Object
                    (
                        [mailservice] => "Bound Printed Matter"
                        [rate] => 3.53
                    )
                [4] => price Object
                    (
                        [mailservice] => "Media Mail"
                        [rate] => 5.14
                    )
                [5] => price Object
                    (
                        [mailservice] => "Library Mail"
                        [rate] => 4.91
                    )
            )
    )
</code>
</pre>
<p>    <em>International rates:</em></p>
<p>    Test 1:</p>
<pre>
<code>
    $usps = new USPS;
    $usps->setServer("http://testing.shippingapis.com/ShippingAPITest.dll");
    $usps->setUserName("??????????");
    $usps->setWeight(2, 0);
    $usps->setCountry("Albania");
    $price = $usps->getPrice();
</code>
</pre>
<p>    Response 1:</p>
<pre>
<code>
    usps Object
    (
        [server] => http://testing.shippingapis.com/ShippingAPITest.dll
        [user] => ?????????
        [pass] =>
        [service] =>
        [dest_zip] =>
        [orig_zip] =>
        [pounds] => 2
        [ounces] => 0
        [container] => None
        [size] => REGULAR
        [machinable] =>
        [country] => Albania
        [list] => Array
            (
                [0] => intprice Object
                    (
                        [id] => 0
                        [rate] => 87
                        [pounds] => 2
                        [ounces] => 0
                        [mailtype] => "Package"
                        [country] => "ALBANIA"
                        [svccommitments] => "See Service Guide"
                        [svcdescription] => "Global Express Guaranteed (GXG) Document Service"
                        [maxdimensions] => "Max. length 46'', depth 35'', height 46'' and max. girth 108''"
                        [maxweight] => 22
                    )
                [1] => intprice Object
                    (
                        [id] => 1
                        [rate] => 96
                        [pounds] => 2
                        [ounces] => 0
                        [mailtype] => "Package"
                        [country] => "ALBANIA"
                        [svccommitments] => "See Service Guide"
                        [svcdescription] => "Global Express Guaranteed (GXG) Non-Document Service"
                        [maxdimensions] => "Max. length 46'', depth 35'', height 46'' and max. girth 108''"
                        [maxweight] => 22
                    )
            )
    )
</code>
</pre>
<p>    Possible errors:</p>
<pre>
<code>
    usps Object
    (
        [server] => http://testing.shippingapis.com/ShippingAPITest.dll
        [user] => ???????????
        [pass] =>
        [service] => Alll
        [dest_zip] => 20008
        [orig_zip] => 10022
        [pounds] => 10
        [ounces] => 5
        [container] => Flat Rate Box
        [size] => LARGE
        [machinable] => true
        [country] => USA
        [error] => error Object
            (
                [number] => -2147219487
                [source] => Rate_Respond;SOLServerRatesTest.RateV2_Respond
                [description] => "Invalid value for package size."
                [helpcontext] => 1000440
                [helpfile] =>
            )
    )
</code>
</pre>
<p>Downlod this freeware PHP script: <a id="p35" href="http://www.varnagiris.net/wp-content/uploads/2006/05/USPS.ZIP" onclick="javascript: pageTracker._trackPageview('/downloads/USPS');">USPS rates calculator v1.2</a></p>
<p>Please make a donation of <strong>1$</strong> if you find our software useful and want to support the continued development.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="algirdas@varnagiris.net"/>
<input type="hidden" name="item_name" value="USPS Rates Class"/>
<input type="hidden" name="amount" value="1.00"/>
<input type="hidden" name="buyer_credit_promo_code" value=""/>
<input type="hidden" name="buyer_credit_product_category" value=""/>
<input type="hidden" name="buyer_credit_shipping_method" value=""/>
<input type="hidden" name="buyer_credit_user_address_change" value=""/>
<input type="hidden" name="no_shipping" value="0"/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="tax" value="0"/>
<input type="hidden" name="lc" value="US"/>
<input type="hidden" name="bn" value="PP-DonationsBF"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px" onclick="javascript: pageTracker._trackPageview('/goal/donate.html');" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" style="border:0px" /><br />
</form>
<p>Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2006/05/04/php-usps-rates-calculator/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>PHP: UPS Address Validation tool</title>
		<link>http://www.varnagiris.net/2006/03/11/php-ups-address-validation-tool/</link>
		<comments>http://www.varnagiris.net/2006/03/11/php-ups-address-validation-tool/#comments</comments>
		<pubDate>Sat, 11 Mar 2006 10:28:14 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[UPS]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/2006/03/11/php-ups-address-validation-tool/</guid>
		<description><![CDATA[Free php UPS address validation tool. With UPS Address Validation, available in the latest XML technology, you don&#8217;t have to worry about your customers entering incorrect address information. If customers make a mistake, UPS Address Validation alerts them with an error message, ensuring that errors are corrected at the point of entry long before orders [...]]]></description>
			<content:encoded><![CDATA[<p>Free php UPS address validation tool.</p>
<p>With UPS Address Validation, available in the latest XML technology, you don&#8217;t have to worry about your customers entering incorrect address information. If customers make a mistake, UPS Address Validation alerts them with an error message, ensuring that errors are corrected at the point of entry long before orders leave the shipping dock. This reduces costly returns for you and headaches for your customers.</p>
<p>UPS Address Validation uses U.S. Postal Service guidelines to thoroughly check the city, state and postal code of every shipment. UPS provides up to ten alternate addresses, including an accuracy rate that lets your customers know how closely the address they entered matches the suggested address.<span id="more-32"></span></p>
<p>In order to start using this UPS address validation tool you need to implement these steps:</p>
<ul>
<li>Create a Tools UserId and Password.</li>
<li>License the Tools and receive your Developer Key.</li>
<li>Get an XML Access Key.</li>
</ul>
<p>Do it at www.ec.ups.com</p>
<p>Here is some information how UPS address validator is working.<br />
To receive Address Validation information, an application sends a request to the Address Validation interface.<br />
The Address Validation request must contain one of the following input combinations:</p>
<ul>
<li>City, State, and Postal Code</li>
<li>City</li>
<li>Postal Code</li>
<li>City and State</li>
<li>City and Postal Code</li>
<li>State and Postal Code</li>
</ul>
<p>Once the request has been successfully submitted, the Address Validation tool returns the following output data for each match (the closest match is returned first):</p>
<ul>
<li>Rank</li>
<li>Quality</li>
<li>City</li>
<li>State</li>
<li>Low-end postal code match</li>
<li>High-end postal code match</li>
</ul>
<p>How to use this free PHP tool?<br />
<code><br />
require_once("upsaddress.php");<br />
$ups = new upsaddress("ACCESSKEY1234567", "userId", "password");<br />
$ups->setCity("Miami");<br />
$ups->setState("FL");<br />
$ups->setZip("33110");<br />
$response = $ups->getResponse();<br />
</code><br />
And here is the response:</p>
<pre><code>
upsaddress Object
(
    [accessKey] => ACCESSKEY1234567
    [userId] => userId
    [password] => password
    [url] => https://wwwcie.ups.com/ups.app/xml/AV
    [city] => Miami
    [state] => FL
    [zip] => 33110
    [statuscode] => 1
    [statusdescription] => Success
    [error] =>
    [list] => Array
        (
            [0] => address Object
                (
                    [rank] => 1
                    [quality] => 1.0
                    [city] => MIAMI
                    [state] => FL
                    [zipLow] => 33110
                    [zipHigh] => 33112
                )
        )
)
</code></pre>
<p><a id="p33" href="http://www.varnagiris.net/wp-content/uploads/2006/03/upsaddress.zip" title="UPS address validation" onclick="javascript: pageTracker._trackPageview('/downloads/UPS');">Download free php UPS address validation tool</a></p>
<p>Please make a donation of <strong>1$</strong> if you find our software useful and want to support the continued development.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="algirdas@varnagiris.net"/>
<input type="hidden" name="item_name" value="USPS Address Validation"/>
<input type="hidden" name="amount" value="1.00"/>
<input type="hidden" name="buyer_credit_promo_code" value=""/>
<input type="hidden" name="buyer_credit_product_category" value=""/>
<input type="hidden" name="buyer_credit_shipping_method" value=""/>
<input type="hidden" name="buyer_credit_user_address_change" value=""/>
<input type="hidden" name="no_shipping" value="0"/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="tax" value="0"/>
<input type="hidden" name="lc" value="US"/>
<input type="hidden" name="bn" value="PP-DonationsBF"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px" onclick="javascript: pageTracker._trackPageview('/goal/donate.html');" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" style="border:0px" /><br />
</form>
<p>Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2006/03/11/php-ups-address-validation-tool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
