doudi5524 2011-04-10 10:23
浏览 29

Facebook API:你如何获得最后创建的图片的网址?

How can I get the url of the picture I just uploaded to facebook through the API?

I need the user to make it its profile picture and I want to give him a fast link to go there.

  • 写回答

2条回答 默认 最新

  • douwen8424 2011-04-10 11:06
    关注

    Alright, so using the Graph API you need to do this:

    • Retrieve a list of of all albums
    • Determine which album was changed most recently
    • Retrieve a list of photos in that album
    • Determine which photo was changed most recently

    Here's how you do it:

    First you call: https://graph.facebook.com/me/albums

    Which gives you a list a list of all the albums, each album has a key called "updated_time". Loop through all the albums and compare them to see which one is the most recent one.

    When you have found the most recent one you take the id of that album and call: https://graph.facebook.com/{ the album id }/photos

    This will give you a list of all the photos in that album. Each photo has a key called "created_time". Use that to determine which photo is the most recently created. When you have done that you can just take the value in the key "source" which is an url to the full scale of the picture.

    If you want a smaller picture there's a key called "images" which contains a list of 4 different sizes; 590x480, 221x180, 130x105 and 92x75. Each of those items in the list has the "source" key.

    评论

报告相同问题?