Home > OS >  Check List of facebook link is FB page or FB profile?
Check List of facebook link is FB page or FB profile?

Time:12-28

I have a list of facebook links. I want to check if the link is Fb profile or Fb page.

Example

data = [
'https://www.facebook.com/<username-profile-1>',
'https://www.facebook.com/<username-fanpage>',
'https://www.facebook.com/<username-profile-2>',
'https://www.facebook.com/<username-fanpage-xxx>',
];

function checkFbLinks(data) {
  // code here
}

Result

FBProfile = [
'https://www.facebook.com/<username-profile>',
'https://www.facebook.com/<username-profile-2>',
];
FBFanPage = [
'https://www.facebook.com/<username-fanpage>',
'https://www.facebook.com/<username-fanpage-xxx>',
];

I tried researching and discovered this API.

https://graph.facebook.com/v12.0/<username>/posts?limit=31&access_token=<access_token>

If it is a FB Page, it will return a list of posts, otherwise it will return an error for FB profile.
But with a list of links (maybe 100 - 200 links), this way is not optimal.

CodePudding user response:

For lots of calls in a row, it is best to use Batch Requests: https://developers.facebook.com/docs/graph-api/batch-requests/

Be aware of the limitations, Batch Requests do not circumvent API limits.

  • Related