1

FacebookGraphAPIを使用しています。

すべてのユーザーのFacebookプロフィール写真のフルサイズの画像をダウンロードしたいと思います。

https://graph.facebook.com/<user alias>/pictureユーザーの現在のプロフィール写真の小さなサムネイルにアクセスできます。

ユーザーのフルサイズのプロフィール写真をダウンロードしたい場合は、この擬似コードのようなことをする必要があるようです...

# Get albums
albums = fetch_json('https://graph.facebook.com/<user alias>/albums')

# Get profile pictures album
profile_picture_album = albums['data']['Profile Pictures'] # Get profile picture album

# Get the pictures from that album
profile_pictures = fetch_json('https://graph.facebook.com/<profile_picture_album_id>/photos')

# Get the most recent (and therefore current) profile picture
current_profile_picture = profile_pictures['data'][0]
image = fetch_image_data(current_profile_picture['source'])

問題は、これには2つの異なるAPIアクセスと画像のダウンロードが必要なことです。また、アルバムにアルバムや写真がたくさんある場合は、ページングを処理する必要があります。

ユーザーの現在のプロフィール写真にアクセスするためのより速く/より簡単な方法があるはずです。誰か知っていますか?

(参考:私はたまたまこれを行うためにPythonを使用していますが、答えは言語に依存しないと思います)

4

2 に答える 2

7

私はあなたが1つの素晴らしいステップでそれを行うことができるとは思いませんが、あなたにはいくつかの選択肢があります:

1.1。

large写真を取得するときのtype引数を指定できます(ただし、最大200pxしか取得できません)。

http://graph.facebook.com/UID/picture?type=large

2.2。

プロフィール写真アルバムのカバー写真を取得できます。これは常に現在のプロフィール写真です。

https://graph.facebook.com/UID/albums?access_token=TOKEN

これは次の線に沿って何かを返します:

{
         "id": "123456781234",
         "from": {
            "name": "FirstName Surname",
            "id": "123456789"
         },
         "name": "Profile Pictures",
         "link": "http://www.facebook.com/album.php?aid=123456&id=123456789",
         "cover_photo": "12345678912345123",
         "privacy": "friends",
         "count": 12,
         "type": "profile",
         "created_time": "2000-01-23T23:38:14+0000",
         "updated_time": "2011-06-15T21:45:14+0000"
      },

その後、以下にアクセスできます。

https://graph.facebook.com/12345678912345123?access_token=TOKEN

そして、画像サイズを選択します。

{
   "id": "12345678912345123",
   "from": {
      "name": "FirstName Surname",
      "id": "123456789"
   },
   "name": "A Caption",
   "picture": "PICTUREURL",
   "source": "PICTURE_SRC_URL",
   "height": 480,
   "width": 720,
   "images": [
      {
         "height": 608,
         "width": 912,
         "source": "PICTUREURL"
      },
      {
         "height": 480,
         "width": 720,
         "source": "PICTUREURL"
      },
      {
         "height": 120,
         "width": 180,
         "source": "PICTUREURL"
      },
      {
         "height": 86,
         "width": 130,
         "source": "PICTUREURL"
      },
      {
         "height": 50,
         "width": 75,
         "source": "PICTUREURL"
      }
   ],
   "link": "FACEBOOK_LINK_URL",
   "icon": "FACEBOOK_ICON_URL",
   "created_time": "2000-01-15T08:42:42+0000",
   "position": 1,
   "updated_time": "2011-06-15T21:44:47+0000"
}

そして、あなたPICTUREURLの選択を選択してください。

3.3。

このブログの礼儀:

//get the current user id
FB.api('/me', function (response) {

  // the FQL query: Get the link of the image, that is the first in the album "Profile pictures" of this user.
  var query = FB.Data.query('select src_big from photo where pid in (select cover_pid from album where owner={0} and name="Profile Pictures")', response.id);
  query.wait(function (rows) {

    //the image link
    image = rows[0].src_big;
  });
});

私は引用に信用を持っていませんが、テストサンプルで遊んでいるときに基本的に同じFQLクエリを思いつきました。私がググったとき、この男はちょうど私をパンチに打ち負かしましたFB.Data.query。私はあなたがそれをPythonに編集しなければならないだろうと想像します、もしあなたがそれをPythonで望むなら、私は掘り下げることができます。

于 2011-06-28T21:12:43.720 に答える
4

これは、プロフィール画像の元のフルサイズバージョンを示しています。

https://graph.facebook.com/someuser/picture?width=9999&height=9999

于 2013-02-25T14:42:30.620 に答える