Obtaining a user context identifier for an Open Open Graph API request

I am currently creating an experimental social network to study the impact of social media on customer behavior.

My users register through Facebook OAuth. I store their access tokens and request the Open Graph API for information about them.

I am trying to use all_mutual_friendsedge for a given user context using an access token from one of my users, but I have not found anywhere how to get user-context-idwhich is required to get this information.

This is not the identifier of the user from whom you want to get mutual friends. I tried this and got an error.

I looked through the Open Graph docs and found nothing about it user-context-id.

How to get it?

+4
source share
1 answer

Oddly enough, the docs do not indicate how to get the context identifier, but I managed to get it by digging a bit.

Here's how you could do to get the data all_mutual_friends:

GET /{user-id}?fields=context.fields%28all_mutual_friends%29&access_token={other-user-access-token}

Then the response will indicate the context identifier.

{
  "context": {
    "all_mutual_friends": {
      "data": [
        {
          "id": "1381033095543871",
          "name": "Dave Amiaaehjighi Putnamwitz",
          "token": <user token>,
          "picture": {
            "data": {
              "is_silhouette": true,
              "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/c15.0.50.50/p50x50/10354686_10150004552801856_220367501106153455_n.jpg?oh=82c2ce067f9c7f2c0a66d1efb16730e7&oe=5670F72F&__gda__=1450287355_17925d7381c8da5663c2349483f4b032"
            }
          }
        }
      ],
      "paging": {
        "cursors": {
          "before": "MTM4MTAzMzA5NTU0Mzg3MQZDZD",
          "after": "MTM4MTAzMzA5NTU0Mzg3MQZDZD"
        }
      },
      "summary": {
        "total_count": 1
      }
    },
    "id": <Context id>
  },
  "id": "1375274282788732",
}

This context identifier can then be used to

GET /{user-context-id}/all_mutual_friends/

But this step is pretty useless, since we get the data in the first request.

It would be nice if Facebook updated its documents to reflect reality.

+9
source

Source: https://habr.com/ru/post/1607177/


All Articles