Skip to content

Instantly share code, notes, and snippets.

@EremenkoAndrey
EremenkoAndrey / gist:660d1ff43d7dde0c0c1c079750202d03
Last active January 22, 2018 10:18
Проверка существования свойства в объекте
/*
Принимает объект и строковое представление вложенного в объект свойства
Примеры:
const obj = {test1:{test5: true}};
checkExistProperty(obj, 'obj.test1.test5'); // true
const obj = {test1:[{test5: true}]};
checkExistProperty(obj, 'obj.test1[0].test5'); // true
checkExistProperty(obj, 'obj.test1.test5'); // false
return bool
@EremenkoAndrey
EremenkoAndrey / gist:a50058e13837948b0119490b9b202692
Created January 14, 2018 15:10 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter