1
0

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のプロフィール画像がデフォルトのシルエットか判別する方法

Posted at

facebookアプリを開発していると、facebookのプロフィール画像が設定されていない場合に何か処理を行いたいときがあります。
しかしfacebookのプロフィール画像が設定されているか調べる方法が見つかりにくかったので、このエントリーで共有します。

プロフィール画像へのURLはhttp://graph.facebook.com/<FacebookユーザーID>/pictureです。
そしてプロフ画像が設定されているか調べる方法は?redirect=falseを追加して、次のURLにアクセスします。

http://graph.facebook.com/<FacebookユーザーID>/picture?redirect=false

すると以下のようなjsonレスポンスが返ってきます。
このis_silhouettetrueだったら、プロフィール画像が設定されていない状態です。

{
   "data": {
      "is_silhouette": false,
      "url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/12803221_1204592706237252_3924866717269900224_n.jpg?oh=d0bd66a705863c3fa552877a704e0652&oe=5A54FA7E"
   }
}
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?