7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Facebookユーザー名からFacebookユーザー情報(IDとかその辺)を調べる

Posted at

Facebookと連携しているアプリで、ユーザーのFacebookIDを知りたい状況が発生。

https://www.facebook.com/profile.php?id=012345678901234567890

↑の様なURLのユーザーならそのままid=以下を取ればいい。

でも

https://www.facebook.com/{USERNAME}

↑の様なURLを設定しているユーザーだと工夫が必要。

例えば、Mark ZuckerbergのURLは↓な感じ。
本人のタイムラインページへ行くとURL欄に出てくる。

https://www.facebook.com/zuck

このURLのwwwの部分をgraphに変える。

https://graph.facebook.com/zuck

これをブラウザでアクセスしたり、curlでアクセスしたりすると、JSONでレスが返ってくる。

{
  id: "4",
  name: "Mark Zuckerberg",
  first_name: "Mark",
  last_name: "Zuckerberg",
  link: "https://www.facebook.com/zuck",
  username: "zuck",
  gender: "male",
  locale: "en_US"
}

↑の様に個人情報が見れちゃう。
このidの部分がFacebookのUserIdになっている。

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?