Skip Menu |

This queue is for tickets about the WWW-Google-URLShortener CPAN distribution.

Report information
The Basics
Id: 101689
Status: resolved
Priority: 0/
Queue: WWW-Google-URLShortener

People
Owner: MANWAR [...] cpan.org
Requestors: aston.martin.za [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.12



Subject: Errors not being caught
Date: Fri, 23 Jan 2015 08:51:37 +0200
To: bug-WWW-Google-URLShortener [...] rt.cpan.org
From: Dale Hayward <aston.martin.za [...] gmail.com>
To whom it may concern While using the perl module and the goo.gl api comes back with am error it crashes my script and the error is displayed in the apache error logs. The error is "WWW::Google::URLShortener::shorten_url(): request to API failed (status: 403)" System details 2.6.32-40-server #87-Ubuntu SMP Tue Mar 6 02:10:02 UTC 2012 x86_64 GNU/Linux perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi perl module version WWW-Google-URLShortener-0.11 Regards, Dale
Hi, New code has been pushed as below: https://github.com/Manwar/WWW-Google-URLShortener/commit/86f986c7776910aba140f75e21d165a9fee7be12 Please give it a go. Best Regards, Mohammad S Anwar
Resolved.
Subject: Re: [rt.cpan.org #101689] Resolved: Errors not being caught
Date: Wed, 28 Jan 2015 10:03:16 +0200
To: bug-WWW-Google-URLShortener [...] rt.cpan.org
From: Dale Hayward <aston.martin.za [...] gmail.com>
I have updated to the latest WWW::Google::URLShortener from cpan and I get the error below. WWW::Google::URLShortener::shorten_url(): request to API failed (status: 403) Regards, Dale On 27 January 2015 at 18:42, Mohammad Sajid Anwar via RT < bug-WWW-Google-URLShortener@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=101689 > > > According to our records, your request has been resolved. If you have any > further questions or concerns, please respond to this message. >
Hi Dale, Please accept my apology for the inconvenience. Below is what I see when I test the URL against the package WWW::Google::URLShortener v0.13. Show quoted text
>>> My system information
manwar@ubuntu:~/$ uname -a Linux ubuntu 2.6.32-71-generic #138-Ubuntu SMP Thu Dec 18 17:38:32 UTC 2014 i686 GNU/Linux Show quoted text
>>> My perl environment
manwar@ubuntu:~/$ perl -v This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi Copyright 1987-2009, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. Show quoted text
>>> My test run
manwar@ubuntu:~/$ perl test-WWW-Google-URLShortener.pl <your_api_key> Using WWW::Google::URLShortener 0.13 Original URL: [ http://www.millwardb.co.za/Survey/index.php?ap=NjgxfjB%2BMzM2MDg%3D ] Shorten URL : [ http://goo.gl/GoF6z7 ] Show quoted text
>>> My test script
manwar@ubuntu:~/my-github/t$ cat test-WWW-Google-URLShortener.pl #!/usr/bin/perl use strict; use warnings; use WWW::Google::URLShortener; my $api_key = $ARGV[0]; my $url = 'http://www.millwardb.co.za/Survey/index.php?ap=NjgxfjB%2BMzM2MDg%3D'; my $google = WWW::Google::URLShortener->new({ api_key => $api_key }); print "Using WWW::Google::URLShortener $WWW::Google::URLShortener::VERSION\n"; print "Original URL: [ $url ]\n"; print "Shorten URL : [ ", $google->shorten_url($url), " ]\n"; manwar@ubuntu:~/$ Please let me know if I missed anything. Best Regards, Mohammad S Anwar
Subject: Re: [rt.cpan.org #101689] Errors not being caught
Date: Sun, 22 Mar 2015 14:58:51 +0200
To: bug-WWW-Google-URLShortener [...] rt.cpan.org
From: Dale Hayward <aston.martin.za [...] gmail.com>
In the perl module you are only returning the id if the URL was shortened, how do I catch the error so I know if the link was not shortened? On 27 January 2015 at 18:42, Mohammad Sajid Anwar via RT < bug-WWW-Google-URLShortener@rt.cpan.org> wrote: Show quoted text
Hi, Here is line from the method shorten_url() from the package WWW::Google::URLShortener: my $response = $self->post($url, $headers, $content); Here the method post() is defined in the package WWW::Google::UserAgent. In the method post(), it throws exception on failure as shown below: unless ($response->{success}) { WWW::Google::UserAgent::Exception->throw({ method => $caller[3], message => "request to API failed", code => $response->{status}, reason => $response->{reason}, filename => $caller[1], line_number => $caller[2] }); } Hope this answers your question. Best Regards, Mohammad S Anwar
Subject: Re: [rt.cpan.org #101689] Errors not being caught
Date: Mon, 23 Mar 2015 14:59:56 +0200
To: bug-WWW-Google-URLShortener [...] rt.cpan.org
From: Dale Hayward <aston.martin.za [...] gmail.com>
when I look at the repository at https://github.com/Manwar/WWW-Google-URLShortener/blob/master/lib/WWW/Google/URLShortener.pm it show version 0.13 and the code above is not in there. On 22 March 2015 at 21:17, Mohammad Sajid Anwar via RT < bug-WWW-Google-URLShortener@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=101689 > > > Hi, > > Here is line from the method shorten_url() from the package > WWW::Google::URLShortener: > > my $response = $self->post($url, $headers, $content); > > Here the method post() is defined in the package WWW::Google::UserAgent. > In the method post(), it throws exception on failure as shown below: > > unless ($response->{success}) { > WWW::Google::UserAgent::Exception->throw({ > method => $caller[3], > message => "request to API failed", > code => $response->{status}, > reason => $response->{reason}, > filename => $caller[1], > line_number => $caller[2] }); > } > > Hope this answers your question. > > Best Regards, > Mohammad S Anwar >
Hi, The reason you don't see there is because it is an external CPAN module. Here is the link to the distribution WWW::Google::UserAgent, https://github.com/Manwar/WWW-Google-UserAgent/blob/master/lib/WWW/Google/UserAgent.pm Hope this answer your question. Best Regards, Mohammad S Anwar
Hi, As per the last comment, it is considered to be close now. If you still have any further question, please give me a shout. Best Regards, Mohammad S Anwar