Helps to get IDs or screen names from links to social network accounts
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
spec
.gitignore
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
ids_please.gemspec

README.md

IDs, please

Build Status ids_please API Documentation

IDs, Please

Grab some hidden in html data from social account page. Get social network IDs or screen names from links to social network accounts.

Sometimes you need to get a social network account name from a link. To store a screen name in your database instead of parsing the link every time, or maybe to work with these accounts using social network APIs (as I do). Would be easier to have a library that extracts this kind of information from all known social networks for your pleasure.

Amplifr

Sponsored by Evil Martians

Installation

gem install ids_please

Or, put this in your Gemfile:

gem 'ids_please'

Usage

This gem works in two modes – you can get real data from social network by HTTP request and page parsing and you can just parse a link to social account to find username/id. Sometimes username from link can't be used with social network's API, in this case, try to get real ID with grab mode.

Grabbing data from social account's page

This functionality works through real HTTP requests, so if you feed it with many links – it can take a while.

As Facebook shows data only from public pages and public groups – in most cases you can't gather data from any profile page. Same thing about private Instagram accounts, profiles and private groups in vk.

Also, you should provide real URLs with right protocols. For example, you will not receive any data from http://facebook.com/Microsoft, but from https://facebook.com/Microsoft you'll receive all data as in example below:

ids = IdsPlease.new('https://instagram.com/microsoft/', 'https://facebook.com/Microsoft')
ids.grab
=> {:instagram=>
    [IdsPlease::Grabbers::Instagram#70339427221180
      @link=https://instagram.com/microsoft/,
      @network_id=524549267,
      @avatar=https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10729318_654650964633655_619168277_a.jpg,
      @display_name=Microsoft,
      @username=microsoft,
      @data={:bio=>"The official Instagram account of Microsoft. Celebrating people who break boundaries, achieve their goals, and #DoMore every day.", :website=>"http://msft.it/MSFTDoMore"}],
    :facebook=>
    [IdsPlease::Grabbers::Facebook#70339427168960
      @link=https://facebook.com/Microsoft,
      @network_id=20528438720,
      @avatar=https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/394366_10151053222893721_1961351328_n.jpg?oh=f3efc47a669cf291221ca421eaf016fb&oe=55C61365&__gda__=1440162054_3bf920ed0b4c0c7873c4ec44affcec15,
      @display_name=Microsoft,
      @username=Microsoft,
      @data={:type=>"company", :description=>"Welcome to the official Microsoft Facebook page, your source for news and conversation about..."}
    ]
   }

insta = ids.grabbed[:instagram].first
insta.avatar
=> "https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10729318_654650964633655_619168277_a.jpg"

Social networks supported for grabbing at the moment:

Link parsing

ids = IdsPlease.new('https://twitter.com/gazay', 'http://facebook.com/alexey.gaziev')
ids.parse
puts ids.parsed[:twitter]  # => ["gazay"]
puts ids.parsed[:facebook] # => ["alexey.gaziev"]

puts ids.original           # => ["https://twitter.com/gazay", "http://facebook.com/alexey.gaziev"]

Or you can just check that the link is for a known social network:

ids = IdsPlease.new('https://twitter.com/gazay', 'http://some-unknown-network.com/gazay')
ids.recognize
puts ids.recognized   # => {:twitter=>[#<URI::HTTP:0x007fea3bba7e30 URL:http://twitter.com/gazay>]}
puts ids.unrecognized # => ["http://some-unknown-network.com/gazay"]

Social networks supported at the moment:

Contributors

  • @gazay

Special thanks to @ai, @yaroslav, @whitequark

Notes

Gem named under an impression of an awesome game called Papers, please.

Logo of gem also was inspired by its logo.

Thanks @dukope for allowing me to do this!

License

The MIT License