Hello friends!
I have my site database where users created their accounts with fb connect system in past, which is stored in 'email' field of my users mysql table, other users who created accounts using my website's own registration form is also stored in email field, but how can i retrieve actual email address of a person who logged in using fb connect system? because i need to make an internal Messaging system for members which is working fine for other users but have no idea how to inform users who has facebook connect accounts because i don't have their actual email addresses stored in my db, which is like in this shape 123456789@fbconnect.apps.sgcdn.net

Any help and suggestion will be appreciated.
Thanks!

Dani AI

Generated

Addresses like 123456789@fbconnect.apps.sgcdn.net are placeholder-style values and cannot be treated as a deliverable mailbox. The reliable way to get a user’s real email is to request the Facebook email permission at login and then read the email field from the Graph API (for example /me?fields=email) using the returned access token — but be aware the Graph API will not always return an email (users who registered with a phone number or who have an unconfirmed email can yield null). As suggested, save the real email value in your users table when it is returned. (javadoc.io)

Suggested migration flow: mark existing rows that contain the fbconnect placeholder, then on next Facebook login re-request the email permission and fetch /me?fields=email; if an email is returned, update the row. Use authType: 'rerequest' to ask again if the user previously denied email. Example (client-side JS with the Facebook JS SDK):

FB.login(function(resp){
  if (resp.status === 'connected') {
    FB.api('/me', {fields: 'id,email'}, function(user){
      // POST user.id and user.email to your server to update DB
    });
  }
}, {scope: 'email', authType: 'rerequest'});

This pattern (request email, then query /me?fields=email) is the common approach. (stackoverflow.com)

If the Graph API returns null or the user won’t re-authorize, present an in-site prompt to collect and verify an email address (make it part of profile settings or a required step before sending external messages). Respect consent and anti-spam rules — don’t overwrite a verified email accidentally, and do not send unsolicited mail. (javadoc.io)

Quick SQL/PHP examples to detect placeholders and update when you get a real email:

SELECT id,email FROM users
WHERE email LIKE '%@fbconnect.%' OR email LIKE '%@fbconnect.apps.%';
$stmt = $pdo->prepare('UPDATE users SET email = ?, email_verified = 1 WHERE fb_id = ? AND (email LIKE ? OR email LIKE ?)');
$stmt->execute([$email, $fb_id, '%@fbconnect.%','%@fbconnect.apps.%']);

Only update rows that match your placeholder pattern; otherwise require users to explicitly change their email in profile.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.