facebook-graph-apigraph-api-explorer

Confusion of post author ID in facebook graph API


I have a little script to grab a post's meta data from facebook, a sample URL for data grabbing is as below.

https://graph.facebook.com/v2.4/176151725813200_1452040848453513?fields=from&access_token=my_own_user_access_token

It returns one entry as below.

{
    from: {
        name: "Tracy Low",
        id: "1452298575094407"
    },
    id: "176151725813200_1452040848453513",
}

This seems an OK entry until I tried to query further on the author's id "1452298575094407" in Facebook's Graph API Explorer. It throws an error to me.

{
    "error": {
        "message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
        "type": "GraphMethodException",
        "code": 100
    }
}

If I script the call using my user access token,

https://graph.facebook.com/v2.4/1452298575094407?access_token=my_own_user_access_token

a good entry is returned.

{
    name: "Tracy Low",
    id: "1452298575094407"
}

If I query the same post ID in Graph API Explorer, '176151725813200_1452040848453513?fields=from', I get

{
    "from": {
        "name": "Tracy Low",
        "id": "1449338978723700"
    },
    "id": "176151725813200_1452040848453513"
}

Look at the "from.id", now it's a different value! This new value "1449338978723700" can be queried in Graph API Explorer. "1449338978723700?fields=id" ->

{
    "id": "1449338978723700"
}

When I append the ID value to "http://www.facebook.com", the first id 1452298575094407 leads me to the correct profile and the second id 1449338978723700 complains the profile is not available.

API version: 2.4/2.3

It's not blocking my script but the strange behaviour is quite disconcerting.


Solution

  • Figured out why. The two different IDs are app-scope user ID. https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

    Though I still can't really figure out how would facebook works out which profile to redirect to when I append the app-scope id to http://www.facebook.com/, when the appid is not present.

    http://www.facebook.com/145229857509440 (Redirected to valid profile) http://www.facebook.com/1449338978723700 (Complained profile not available)