부분 중단share-external
Metadata requests often misidentify pages as users
1

If I make a graph API request for some metadata details on several pages, the API response will incorrectly indicate that the page is a user. This isn't the case for every page, but it is consistent for those pages that are misidentified.

For example, https://www.facebook.com/p/Senator-Varun-Ghosh-61555898371067/. This is a public page - it says so right on the profile.

If I request https://graph.facebook.com/v16.0/61555898371067?fields=id,name,metadata.fields(type)&metadata=1 the result is:

{"id":"61555898371067","name":"Senator Varun Ghosh","metadata":{"type":"user"}}

Similarly, the URL https://www.facebook.com/people/Senator-Fatima-Payman/100077402947532/ has a /people/ path, but it is clearly labeled as a page in the "intro" box. A request to the Graph API says that it is a user:

{"id":"100077402947532","name":"Senator Fatima Payman","metadata":{"type":"user"}}

One that works correctly is the page https://www.facebook.com/PeterDuttonMP:

https://graph.facebook.com/v16.0/PeterDuttonMP?fields=id,name,metadata.fields(type)&metadata=1

{"id":"552968198133394","name":"Peter Dutton","metadata":{"type":"page"}}

This isn't controlled by whether I make a graph API request for a numeric ID or a human-readable name - both return the same result in all cases.

Is this a bug in the graph API? Or is there some other way to tell whether the URL I have is for a user or a page that is more reliable?

David
질문함 약 4개월 전
선택한 답변
1

I don't think anyone still uses that functionality nowadays. What's your use case for this?

7월 28일 오전 6:01
Lars
David

You don't think people use what functionality - metadata? It seems pretty foundational to me.

This is for onboarding users to my app. They give me the URL of their page or user, and I need to store the numeric ID so I can make further API requests, as well as the type so that I know what fields I can request.

7월 29일 오후 2:52
Lars

If you use the API to retrieve data you shouldn’t need to use that functionality. If users key in account names you may need it.

7월 29일 오후 3:27
David

I don't understand, can you rephrase that? What functionality are you referring to? What does it mean for a user to key in account names?

8월 1일 오후 2:00
Lars

What’s the source of these IDs. Seems it’s not the API but your use case relies on data freely imputed by a user? Nearly all API calls are separated by user/page so there shouldn’t be an need to get the type (user or page) by making additional requests.

8월 1일 오후 4:09
David

The source of the ID is the Graph API response. I start with the URL of their Facebook profile or page, extract the identifier from that URL, and send the requests as described in the OP. This is all documented and supported and functions in the graph API explorer; the problem is that the type in the metadata response does not match the actual type of the page.

8월 8일 오전 11:57
Lars

What a weird use case. Sounds like you do request random user IDs for some reason. However, like mentioned already, use the API like intended and there is no need to get a confirmation as metadata that lets you know what you requested.

8월 8일 오후 12:12
David

what would be using the API as intended? I'm getting the metadata, the problem is that the type it gives me is not correct.

8월 8일 오후 1:27
Lars

Most devs know what type of object they request

8월 8일 오후 2:35