Facebook Graph API - get a photos album ID

后端 未结 9 2168
小蘑菇
小蘑菇 2020-12-31 09:32

I\'m writing an application that uploads a photo to facebook. I\'m not supplying an album ID so an album is created on behalf of my app.

My question is: how do I get

9条回答
  •  一整个雨季
    2020-12-31 09:52

    Richard Barnett's solution works well for me, I use this as an FQL query through the Graph API to get a JSON response like I would for any other Graph API query:

    https://graph.facebook.com/fql?q=select+album_object_id+FROM+photo+WHERE+object_id='[PHOTOID]'
    

    This returns:

    {
       "data": [
          {
             "album_object_id": "10150531092908837"
          }
       ]
    }
    

    Then you can access the album ID using:

    data[0]->album_object_id;
    
    ?>
    

    This is the cleanest solution i've found as Facebook constantly change the format of their photo and album URLs so parsing these with RegEx wont work as a long term fix.

提交回复
热议问题