Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
make facebook counter extraction more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
compeak committed May 31, 2016
1 parent 931390d commit 8c05b12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
3.1 2016-05-31
- Made Facebook counter extraction more robust.

3.0 2016-02-09
- Updated to Mojolicious 6.0.
- Removed obsolete tests for Twitter API.
Expand Down
2 changes: 1 addition & 1 deletion lib/Heise/Shariff.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Heise::Shariff::Cache;
use Mojo::Date;
use Mojo::Loader qw(load_class find_modules);

our $VERSION = '3.0';
our $VERSION = '3.1';

has service_namespaces => sub {['Heise::Shariff::Service']};

Expand Down
4 changes: 2 additions & 2 deletions lib/Heise/Shariff/Service/Facebook.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ sub extract_count {

return undef unless $json;

if (ref $json eq 'ARRAY' && exists $json->[0]->{share_count}) {
if (ref $json eq 'ARRAY' && ref($json->[0]) eq 'HASH' && exists $json->[0]->{share_count}) {
return $json->[0]->{share_count};
}
if (exists $json->{share} && defined($json->{share}->{share_count})) {
if (ref $json eq 'HASH' && ref($json->{share}) eq 'HASH' && defined($json->{share}->{share_count})) {
return $json->{share}->{share_count};
}
return undef;
Expand Down

0 comments on commit 8c05b12

Please sign in to comment.