[ic] LWP::UserAgent

Frank Reitzenstein frank at aussievitamin.com
Thu Mar 10 19:11:21 UTC 2011


Frank Reitzenstein wrote:
> Gert van der Spoel wrote:
>   
>>>>> Hello,
>>>>>
>>>>> I created my own usertag like your ups shipping tags for use in AU.
>>>>>
>>>>> This section retrieves the shipping charge from Australia Post based on
>>>>> weights and postcodes:
>>>>>
>>>>> my $return;
>>>>> my $error="OK";
>>>>> my $content;
>>>>> my
>>>>>     
>>>>>         
>>>>>           
>>>>       
>>>>         
>> $url="http://drc.edeliver.com.au/rateCalc.asp?Height=$height&Length=$length&
>>   
>>     
>>>>       
>>>>         
>> Weight=$weight&Width=$width&Pickup_Postcode=$origin&Destination_Postcode=$zi
>>   
>>     
>>>> p&Country=$country&Service_Type=$modex&Quantity=1";
>>>>   
>>>>       
>>>>         
>>>>> use LWP::UserAgent;
>>>>> my $ua = LWP::UserAgent->new;
>>>>> $ua->timeout(5);
>>>>> $ua->env_proxy;
>>>>> my $aus_post=0;
>>>>> my $response =$ua->get("$url");
>>>>>
>>>>> if ($response->is_success)
>>>>> {
>>>>> $content = $response->content;
>>>>> }
>>>>> else
>>>>> {
>>>>> $aus_post=1;
>>>>> }
>>>>>
>>>>>
>>>>> $content used to return Australia post's web page which looks like this:
>>>>>
>>>>>
>>>>>     
>>>>>         
>>>>>           
>>>>       
>>>>         
>> http://drc.edeliver.com.au/rateCalc.asp?Height=420&Length=210&Weight=100&Wid
>>   
>>     
>>>>       
>>>>         
>> th=460&Pickup_Postcode=6076&Destination_Postcode=298128&Country=KE&Service_T
>>   
>>     
>>>> ype=AIR&Quantity=1
>>>>   
>>>>       
>>>>         
>>>>> But now it returns "".
>>>>>
>>>>> What could blocking my code form the internet?
>>>>>     
>>>>>         
>>>>>           
>>>> Does it not return an error? Tried checking: $response->status_line to
>>>>       
>>>>         
>> see
>>   
>>     
>>>> what value it has?
>>>>
>>>> CU,
>>>>
>>>> Gert
>>>>   
>>>>       
>>>>         
>>> Gert,
>>>
>>> Thankyou for your quick response. I have dumped the status, content and
>>> url to a file:
>>>
>>> STATUS 200 OK
>>> CONTENT
>>> URL
>>>
>>>     
>>>       
>> http://drc.edeliver.com.au/rateCalc.asp?Height=100&Length=100&Weight=1000&Wi
>> dth=100&Pickup_Postcode=6076&Destination_Postcode=01543&Country=US&Service_T
>> ype=SEA&Quantity=1
>>   
>>     
>>> Everything looks ok, but no content. This happened when I upgraded from IC
>>>     
>>>       
>> 5.2 to 5.6 last week. It worked for 4 years.
>>   
>>     
>>> LWP::Simple produces the same result. 
>>>
>>> Regards,
>>>
>>> Frank
>>>     
>>>       
>> Try this script on the commandline and see if that returns anything, just to
>> rule out other factors than IC (although perhaps you already tried this) ==
>> change the path to your perl of course ... 
>>
>> #!/usr/local/bin/perl
>>
>> my $return;
>> my $error="OK";
>> my $content;
>> my $height ='100';
>> my $length ='100';
>> my $weight ='1000';
>> my $width  ='100';
>> my $origin ='6076';
>> my $zip    ='01543';
>> my $country='US';
>> my $modex='SEA';
>>
>> #http://drc.edeliver.com.au/rateCalc.asp?Height=100&Length=100&Weight=1000&W
>> idth=100&Pickup_Postcode=6076&Destination_Postcode=01543&Country=US&Service_
>> Type=SEA&Quantity=1
>>
>> my
>> $url="http://drc.edeliver.com.au/rateCalc.asp?Height=$height&Length=$length&
>> Weight=$weight&Width=$width&Pickup_Postcode=$origin&Destination_Postcode=$zi
>> p&Country=$country&Service_Type=$modex&Quantity=1";
>> print "$url\n";
>>
>> use LWP::UserAgent;
>> my $ua = LWP::UserAgent->new;
>> $ua->timeout(5);
>> $ua->env_proxy;
>> my $aus_post=0;
>> my $response =$ua->get("$url");
>>
>> if ($response->is_success)
>> {
>> $content = $response->content;
>> }
>> else
>> {
>> $aus_post=1;
>> }
>>
>> print "CONTENT: $content\n";
>>
>> If this does not return anything aswell it could be something else. If not
>> then a closer look into IC sounds in order.
>>
>> CU,
>>
>> Gert
>>
>>   
>>     
> Thankyou Gert. That worked fine. As this happened after after an IC
> upgrade (I use dd to mirror the disk, then I upgrade - I host and sell
> from home) I had little doubt that something had changed on Interchange
> between 5.2 & 5.6 to cause this. Thankyou very much for your time.
>
> I will pack this tea tomorrow and send it to the US shipping free!
>
> Regards,
>
> Frank Reitzenstein
>   
Sorry about the messy subject in previous posts. I have the font cranked
up on my pc as I am healing my eyesight by not wearing glasses. It makes
everything cluttered and hard to use..



More information about the interchange-users mailing list