lib/share_counter.rb in share_counter-0.2.0 vs lib/share_counter.rb in share_counter-0.2.1

- old
+ new

@@ -41,12 +41,24 @@ html.gsub! ')', '' return JSON.parse(html)['count'] end def self.seomoz url, access_id, secret + mozrank = 0 + page_authority = 0 + domain_authority = 0 + client = Linkscape::Client.new(accessID: access_id, secret: secret) response = client.urlMetrics(url, cols: :all) - { mozrank: response.data['source'][:mozrank], page_authority: response.data['source'][:page_authority], domain_authority: response.data['source'][:domain_authority]} + + if response.response.code.to_i == 200 + mozrank = response.data['source'][:mozrank] + page_authority = response.data['source'][:page_authority] + domain_authority = response.data['source'][:domain_authority] + return { mozrank: mozrank, page_authority: page_authority, domain_authority: domain_authority } + end + + return { mozrank: mozrank, page_authority: page_authority, domain_authority: domain_authority } end def self.supported_networks %w(reddit twitter facebook linkedin stumbleupon pinterest) end