Facebook Login returns different user id - facebook

about 500 different pages are connected to my app, we provide a seamless expierience on Messenger so we recieve messages from their clients.
The same person which talks on messenger with a connected page has USER_ID_1
Later the same person logs in using our app and we get USER_ID_2
Is there a way to find out that USER_ID_2 is basically the same person as USER_ID_1?
I found out endpoints like /ids_for_pages - but it works only if fanpage and app are owned by the same business. What if there is a situation that we are the app and the page is connected to our app?
Thank you in advance!

Related

Facebook Oauth-enticated users, chat between themselves on website

I have a website where users log in with Facebook. Right now there's no way for users to contact each other.
I was thinking of building a dedicated live messenger with sockets, but I wonder if there's an easier way to allow them to send messages to each other's Facebook Messanger, since they are already logged in with facebook.
There is no API for a chat between two users. Everything in Messenger API is focused on communication between a user and a page.
At most you can use the Send dialog to let a user send a link to their friends, but that requires the user actively using the button, you can not “automate” that; and handling the result will have nothing to do with your site any more, everything after that will happen in messenger only. https://developers.facebook.com/docs/sharing/reference/send-dialog

facebook application for login and messenger same ids?

I am building a facebook messenger bot. And the bot is giving user ids. But it is not clear to me if the messenger ids are the same ids that would be returned if I use the same app and add to it a login feature. Because we already have an app and has a login feature, now we need to build a facebook bot and identify the already existing users in our db that are using the bot.
I have read facebook tutorial about linking 2 different applications to the same business to get consistent ids. But what if I use that same application to login users AND for messengers (by using the add products to the application, and so having one application, one app id) would that work? Would I be getting the same user ids?
PS: I would test myself but I am in an awkward position where the page/database/login app owner is a different person, and they are not big on sharing data, and I am supposed to blindly write a messenger code that is supposed to work when they deploy it.
All help is appreciated, thank you.
You need to use Facebook's ID Matching APIs for this purpose:
Here is the details: https://developers.facebook.com/docs/messenger-platform/identity/id-matching

Create multiple Facebook messenger bots with one app

The Facebook messenger bot API seems to require you create a Facebook app for each bot, for each page. The Facebook app stores the webhook, and connects to the page.
Is there a way to have a single Facebook app for many bots connected to many pages?
If you create a bot to resell to clients as a service, you need to be able to do this. But there does not seem to be any way. You need to create a Facebook app for each client, and go through the Facebook app review process for each page which is very difficult.
How can this be avoided?
Can a single Facebook app have multiple webhooks, or access to multiple pages messages?
You can create one chatbot and can use this bot in multiple Facebook pages. All you need is to store PAGE_ACCESS_TOKEN for each page and response messages to the user with right PAGE_ACCESS_TOKEN. You should get the necessary permissions to get page access tokens by Facebook Login. And then you need to subscribe the page to your chatbot(app): https://developers.facebook.com/docs/graph-api/reference/page/subscribed_apps
One important thing is Facebook generates a unique identifier for users for each page. Some user#A will have a different SENDER_ID/RECIPIENT_ID on different pages.

Implementing Chat On Facebook Web App

This is a not exactly a technical question - sorry in advance .
I have a social web app on Facebook and I want to give my app's users the ability to chat between themselves (exactly the way facebook chat looks). As I see it here are my options :
1 : Regarding the Facebook Chat API http://developers.facebook.com/docs/chat/ it is not clear to me whether this works only for a user's Facebook friends or will I have the ability to let non friends chat too (it is very important since 99% of my users aren't supposed to be Facebook friends). I read it a few times and it seems that this service is only for a Facebook user and his Facebook friends , but maybe I am wrong ?
2 : If I am right and Facebook Chat API is only for friends , what is an easy and safe way to implement a simple chat between 2 users myself? (I am not expecting millions of users on my app so it's not out of the question for my app to implement a chat).
Per Send message to a non-friend facebook user?, you cannot send chat messages via the API between Facebook users that are not connected.

How to architect and design Facebook friends integration into a iPhone app with cloud service

For some reason I can't find this information anywhere. I'm looking to figure out best practices for how to design and architect Facebook integration into an iPhone app that also has a cloud service backing it for my own (non-facebook) data.
Specifically, assume a user is going to authorize Facebook access in my iPhone app and I want to find "your Facebook friends that are also using this app+service".
The Facebook authentication and authorization with iOS SDK is straightforward, and it looks obvious that my service needs to store the user's Facebook User ID. However, I am trying to get clarity on:
Who does the friend lookup against Facebook's server? iPhone client or my service?
Does my service cache anything about the relationship between the friends or is it looked up each time?
I'm ultimately trying to figure out how to get a design that will scale to millions of users and see problems in whether client or the server does the work. If it's the client, then user has to wait for a call to FB OpenGraph, then back to my cloud service to get the intersection of FB friends using my service (+ any other metadata I want to show).
If it's my server, I'm caching information that ultimately has to be sync'd and reconciled with changes to the user's friends list. Also, this doesn't really solve the scale problem since the iPhone app would sign into FB for a given user, send me their Facebook ID, then my service would have to call Facebook OpenGraph server-to-server and still reconcile the FB friends list.
Would love any advice!