facebookfacebook-graph-apifbml

is it possible to retrieve Facebook user name or id from photo URL


If i have facebook users photo's URL, for example: https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/885089_523687507674066_732194510_o.png

Can i retrieve user's name or id which own this photo?


Solution

  • First, fetch the photo_id from the url. For eg:

    Link: https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/885089_523687507674066_732194510_o.png

    PhotoId: 523687507674066

    Then make the \GET request to this ID. Just like this:

    \GET http://graph.facebook.com/523687507674066
    

    (you can validate this link in the browser)

    You'll get the JSON response just like-

    ....
    from: {
      category: "Recreation/sports website",
      name: "Emocje do pełna",
      id: "290868840955935"
    },
    ....
    

    So, you just have to fetch the id from the from paramter