what is change in facebook user id? - facebook

As my application is old and i have saved user id with php-sdk but for some reason i lost my facebook account and also lost my facebook developer account.
So all user of my application have old user id that is format like 1000011102010.... but when i created new facebook account and created new application it start giving me new format of user id 78102000.... now i am totally lost. i am still using php-sdk everything is same but i am getting different user id
$fbuid = $user_info['id'];

This has been asked here dozens of times. Please use the search functionality of StackOverflow before posting a new question.
With the graph API v2.0, the so-called app-scoped user_ids have been introduced. See the docs here:
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

Related

Facebook Messenger Platform: how to get user specific information?

I'm trying the recent released Facebook Messenger Platform and so far so good. Everything worked well and I was able to create a echo bot.
But I'm wondering how I could identify this user that started chatting in my page. For example, when a user started chatting I get a PID user (page specific user id).
Making the follow request to Facebook Graph API:
GET https://graph.facebook.com/v2.6/{PAGE_SPECIFIC_USER_ID}
I discovered that I can just ask for the following fields: first_name,last_name and profile_pic.
So my question is, how could I discover if this user is a current customer of my business page? Is there another way of querying more information (like e-mail and real facebook user id)?
Facebook has updated the messenger platform API (2016-07-01) and introduced a new feature called Account Linking. This can be used to identify a user who has created an account on your website via Facebook Login and you can link the two accounts. Facebook login has its own set of permissions which can be used to get a lot more information via Facebook graph API. You can find the complete list here.
Currently, there's no way to do this. The best way would be to prompt the user to enter their information in chat or give them a link to a mobile login page or some other way of linking their account to the chat.
Messenger Platform 2.0 introduce "ID Matching API" ,that will solve the problem.
https://developers.facebook.com/docs/messenger-platform/connecting-accounts
you can retreive a user information like below using fbmq library https://github.com/conbus/fbmq
# this method will occur when a message received from user
#page.handle_message
def message_handler(event):
user_profile = page.get_user_profile(event.sender_id)
print(user_profile) #first_name, last_name, profile_pic, gender ...

Facebook oauth returns 2 fb ids for one user

I have been maintaining a site that allows users to login using the FB credentials. For the last 2 years this has all been working fine on our servers, still works fine actually.
Now I have added a new integration server. When a user logs in with their FB credentials a different ID is returned, different from the ID they get when they log into our older servers.
When i use either ID in facebook.com i get sent to the proper home page. So it looks like a user has more than one FB ID.
Has anyone seen this before? I am stumped. Have copied the working Facebook app definitions for the older servers, no joy. Stripped down the app definition for the new server, no joy.
One difference is that our new server is using an IP address, not a dns entry. Could that be the problem?
thanks for any help.
With the introduction of API v2.0, Facebook has made user ids app-scoped – meaning, each app will see a different app-scoped id for a user. Purpose is of course to improve user privacy.
https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api
And before you ask: No, you can not get the “real” id from an app-scoped one – and you’re not supposed to.
If you need to identify users across different apps owned by your company, see what it says about the Business Mapping API (litte bit further down in the changelog.)

How do I get a facebook user's most recent messages with another user?

I'm working on a web application in which I show the last time the current user (who authenticates with FB and supplies all relevant permissions) user interacted with another user. Example, my ID is 1526632 and would like to find the date of the last message sent between me and another facebook user (either by username, or id #).
I've been reading through their API and it seems this permission existed in version 2.4 of the Chat API but was since deprecated. Is there a new way for developers to get this information somehow?
My guess is this is not possible via the graph API. Assuming this is true, does facebook have unpublished IMAP access to a user's inbox? Or any other creative ways I can do this?
The Chat API is gone, as you have found out already. There is no replacement, what you want to achieve is not possible in any way. The user inbox is off limits now, i´m afraid.

how to map old facebook id with new facebook scoped id?

Im using FB App for my site, in that FB announced that graph api, new api will return app scoped id instead of fb user_id. I used to store all my FB user_id to table and retrieve data for next time by matching user_id.
Now new api will provide scoped_id its new to all users so how can i figure out this user is already register in our site?
Simply, how to find out the user is already logged with us by comparing or getting user_id ?
how can i get user_id by passing scoped_user_id ?
I think mapping is not necessary, have a look at
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
No matter what version they originally used to sign up for your app, the ID will remain the same for people who have already logged into your app. This change is backwards-compatible for anyone who has logged into your app at any point in the past.

Get Users App-Scoped user id in Facebook Graph API

In advent of the new V2 Facebook Open Graph API, I need to make note of the logged in users 'App-Scoped' user ID, in order to register the id with Parse in order to receive PUSH notifications.
However, as the logged in user I get the Facebook ID instead.
Haven't found anything in the docs to solve this problem yet, so thought I better ask here.
If you created your facebook application before the introduction of graph API 2.0, It will continue to receive the canonical facebook user ID
If you created your facebook application, after the introduction of graph API 2.0, It gives you app scoped id instead of the canonical id.
In this case I assume your application is quite old.Therefor create a new app and it will give you the app scope id.
In facebook document:
"The id of this person's user account. This ID is unique to each app
and cannot be used across different apps. Our upgrade guide provides
more info about this." You only get id with each apps.
more information in here: facebook.developers
The "Facebook ID" as you call it IS the App-scoped User ID.
See https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
The id you get from the api's is an opaque string, and you should use it as such.
If the user has already granted your app access on v1, then your app will continue to receive the same id.
The old users who have registered keep receiving the canonical ID from Facebook for those users, and new users are getting the new scoped ID. Although it is working fine as a long integer, I suggest to change the long field for a string field (unless you already treat it as a string), because we cannot know what Facebook will send here in the future. To keep your code mainly unchanged, create a new internal user id long integer which will be the one your code is already using, and relate it with the string ID from Facebook, which is canonical or scoped, depending if the user registered before or after the migration, and which you will have to manage only for logins, requests, open graph stories, etc.
This way you have not worry about canonical or scoped id EXCEPT one case. Everything works fine, except we found a problem, and maybe somebody can correct me and so help me to solve this: when a new user accept a invite request from an existing user, when your app reads the ID of the sender of the request, I found that Facebook gives you the new scoped id ALWAYS, no mater if the referrer is old or new user. This way, if a user registered before the migration, you have stored the canonical ID, and later, you read a request from this user accepted for a new one, you get the scoped id from the old user, but what you have stored is the canonical one! As result, old users can no more invite new users properly! If anyone knows how getting canonical ids from requests sent for old users, or knows how to obtain the scoped ids for the existing users with canonical ids (to store the new scoped ids in the database) it would be very helpful to hear their suggestions.