Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(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
You can’t perform that action at this time.