Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created January 25, 2014 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/8619199 to your computer and use it in GitHub Desktop.
Save jutememo/8619199 to your computer and use it in GitHub Desktop.
(function () {
var fbPage = function () {
var that = {},
_paths = location.pathname.split('/');
var hasUserName = function () {
return _paths.length == 2;
};
var getId = function () {
if (hasUserName()) {
var req = new XMLHttpRequest();
req.onload = function () {
prompt("このページの ID を表示します。",
JSON.parse(this.responseText).id);
};
req.open("GET", "https://graph.facebook.com" + location.pathname);
req.send();
} else {
prompt("このページの ID を表示します。",
_paths[3]);
}
};
that.getId = getId;
return that;
};
var fb = fbPage().getId();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment