Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get a raw Google+ share count in Rails

Google+ Share Count

While there's no officially documented method in the Google+ API way to get a raw share count, there are some tricks you can do to acheive this.

For this example, we're working in a Rails app with Nokogiri. We'll use Nokogiri to open the Google+ fastbutton tool and return the share count.

require 'open-uri'
require 'nokogiri'

@url = "http://yoursite.com"

googleplus_data = Nokogiri::HTML(open("https://plusone.google.com/_/+1/fastbutton?url=#{@url}"))
self.gplus_count = googleplus_data.css('div#aggregateCount')[0].text.to_i
@ghprod

This comment has been minimized.

Copy link

commented Mar 7, 2016

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.