Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ids_please

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ids_please

  • 2.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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:

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

FAQs

Package last updated on 10 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc