Is it possible to determine the #Facebook.com email address of a user? - facebook

Is it possible to figure out reliably what the Facebook email of any Facebook user would be? I know earlier this was not possible because not all users had a username. But I believe that has changed since...
I'm trying to figure out a way to let a user send a direct message to their friend through my app. The Request feature is pretty messed up now as you cannot send a custom message, which means most friends are probably going to ignore the request.
The type of messages that I am trying to let my users send to their friends would not be considered spam by Facebook, as these are messages sent directly from the user to their friend, except it is done through the app. But it's pointless if the message just says "Joe wants you to try this app..." The usefulness of an app on the Facebook platform is becoming questionable now.

I think that facebook terms and conditions disallow this...
Facebook messaging (i.e., email sent to an #facebook.com address) is designed for communication between users, and not a channel for applications to communicate directly with users."
Despite your caveat at the end of your post I believe that facebook would consider this a message from your app to the user.
In terms of your question, then the user data returned includes 'username' which is the information you need to create the email address.

Is it possible to figure out reliably what the Facebook email of any Facebook user would be? I know earlier this was not possible because not all users had a username. But I believe that has changed since...
Yes, now every user should have a username set – if not by themselves, than FB will have chosen one for them.
Besides that, I think writing to userid#facebook also works.
But I agree with combinatorial’s answer – Facebook explicitly says that this should not be used for app-to-user communication. To judge if your case is OK is up to you – otherwise you might consider using the send dialog instead, that’s more of the “designated” way to have users communicate “through” your app.

If what you are looking for is to give them a new message notification, it is not going to work. Because, if you send an email to the facebook email, it will land in the Others folder in the message box, which is like a spam box.Try mailing your own #facebook id and see what happens.
And Facebook doesnt give any documentation of how to get users #facebook email, most probably because they dont want developers to use it.
Why dont you mail them directly? You can easily get their email by adding email to the scope, and you can catch the email easily too.
$data = file_get_contents("https://graph.facebook.com/me?access_token=xxxxxx");
$data = json_decode($data,true);
$email = $data['email'];
Is that a viable option in your case?

Related

How to send message to specific facebook user from website?

My goal is to make a website, in which user could customize a photo and then provide his friends indicators like name or id. My next task is to fetch that info from database and send messages on specific date to provided users. Ex birthday wishes, greetings, and so on.
I studied facebook send api for a few days now and couldn't find solution for myself. If I want to send message, I need to have Page-scoped id of user, which is acquired when the person text you first, which is not desired, because person wouldn't know what it is.
Also I was looking into Customer matching API, also seems to require the same PSID. The next thing I checked was Send Dialog API, which seems to send messages instantly, but not on the specific date. Also I checked unofficial facebook-chat-api, which asks for user ID, whereas I can find my id, I couldn't find ids of my friends.
So I just want to know is it even possible, if yes, I'd really appreciate your help.
User to User communication is not possible (and not allowed) in an automatic way, there is no API for it except for the Send Dialog. The Messenger platform is for page to user communication only.
Do not use inofficial tools, they are not allowed and might get you banned.

Facebook "out of office" app

I’d like to implement an “out of office” app for Facebook messages but it doesn’t seem technically possible. The idea is simple, let the user define some dates they won’t be reading Facebook messages (i.e.: they're off-line camping) so that when they get a new message we can notify the friend/sender they won’t be able to respond quickly.
I’ve been reading Facebook’s API and, although I can read user’s messages with proper authorization (read_mailbox), I cannot send messages on their behalf.
A workaround would be to get the email address of the sender, and answer with a plan email instead of a Facebook message. But getting the sender's email also requires extended permissions on a per user basis.
I could present the Send Dialog, but logically we want this to work automatically without any user interaction. Also, we could post a private status only visible to the sender, but that doesn’t seem very effective.
This is where I hit the wall. Can you think of a way to implement such functionality?
You can email to username#facebook.com (getting the username from the user id does not require any permissions) – but Facebook’s policies forbid apps from using that in general, because they say these addresses are intended for user-to-user communication.
You could make a point saying, that this was essentially user-to-user communication – but use at own risk. You’re app may be blocked if there’s spam complaints or if Facebook sees you sending a massive amount of messages this way.

Problems of inviting friends through Facebook email

I want my users to invite their friends by sending them Facebook private massage. I am thinking of using send button, but the problem is that each invitation url is different and unique, so if I use send button to do it, I might need to create many send buttons each of which carries an unique href. I think this should work? But ideally, I want users to just select their friends in a multi friend selector and everything's done by just clicking the sending button. Any ideas?
Thanks for any help!
You can generate a unique URL for the message that includes the IDs for all the users the user wants to send the message to. Then, when the recipient accesses the URL and authenticates themselves, you can cross reference the URL and their User ID to what you have in your database.
Without knowing what the message contains, its purpose and what you want to achieve, this is the best approach I can think of.
You won't be able to tell who the message is actually sent to, as Facebook doesn't return the User IDs in the callback, but if you have read_inbox permissions, you should be able to look the User IDs up that way.
i think an better way to approach this is set up an invite system, have an invitation code field in your register.php that you sign into, store that info in user account database and set an number of times it can be used

Facebook request dialog with custom message notification

I have a very simple use case. My app lets users send invitations to his friends, say for a birthday party. Friends then accept the invitation(and app).
I am using RequestDialog to send notifications to multiple users. Notification was sent successfully but the message is confusing to the user as it says
"User A Invited you to try APPNAME. Try Now".
Is there a way to customize this message? It should something like
"User A Invited you to his birthday party using APPNAME. Accept it now"
I believe I cannot use app generated requests as invitees hasn't authorized the app yet.
Any other ideas or workarounds to send notification, message with a link so users can click on it and accept the app and thus accept the birthday invitation?
You should use message parameter of Requests Dialog
message - The Request string the receiving user will see. It appears as a question posed by the sending user. The maximum length is 255 characters. The message value is not displayed in Notifications and can only be viewed on the Apps and Games Dashboard. Invites (requests where the recipient has not installed the app) do not display this value.
I memory serves, Facebook used to let you customize (many years ago), but, probably due to abuse, they no longer allow you to customize what the invitee sees. It's all standard. However, when the user comes to your app to authenticate, you can customize the Enhanced Auth dialog to your content.
I don't think there's a way to customize invite messages, and interestingly, to Usman Ashraf's point, as far as I can tell BranchOut can't do this anymore either (or at least I can't replicate it with their app). If anybody else can replicate it, let me know.
What you might want to do would be to allow
new_style_message: true,
Under your
FB.ui({
method: 'apprequests',
new_style_message: true,
message: "is bringing you to the UPicnic !",
display: "iframe"
},somefunction);
What this does is when the notification is sent to the user(s) , it will show up as the message instead. Not much customization but that's the least I can find.

Facebook Callback JSON does not return email sometimes

Facebook Graph API.
I am requesting email permission and it works all fine except for some users, the json does not return email field. I am not sure why this happens. The code is same and it works great for all users, returns email field except 1 in 100 or so users where it does not have this field in json. All other fields are there.
Has anyone faced this problem before ??
I checked the facebook privacy settings and there is nothing that prevents email from coming in json if user grants email access to facebook app, yet this is happening to me. I searched the net and no one else seems to be facing this issue.
Any hint would be appreciated
Never makes assumptions about what Facebook will send you, never expect every field to be present and never expect a Graph request to do what you want.
Facebook sometimes do things like this, a missing field here and there, a cryptic and unexpected error somewhere else… While it can be no harm be aware that it also happens in critial places like in the signed_request sent when an user launches an app.
You also have to know that 'your' Facebook may not be everyone else's Facebook. They do geographic and somewhat random deployments of their code. An option to hide your e-mail address to every application could appear for someone but not for someone else, without any particular reason.
Considering your particular issue, I doubt there is an option to hide you e-mail address to an app who has the mail permission, but if the permission is not mandatory someone could accept your app and cherry-pick optional permissions later.
I dealing with this issue recently. Apparently, facebook only promise to return "valid email" address. Some account do not having any "valid email". They can be account who using phone for validation, or account that email is expired. I tried with a account which email, lets said "xxxx.gmail.com" is expired, when query that account graph, i unable to get any email shows(by using facebook debugger). However, when i login xxxx.gmail.com in gmail, and re-activate the email, and i query graph api again for the account, it able to return me email.
had the same issue for a while, which caused some heavy head banging against the wall.
in my case the issue was due to the fact that some users have unverified emails or no email at all (when signing up via mobile/SMS).
in this case facebook will not provide an email on the response.
from the facebook docs:
note: this field will not be returned if no valid email address is
available for the user
sources:
https://github.com/mkdynamic/omniauth-facebook/issues/61
Register with Facebook sometimes doesn't provide email (sebastian's and colm's answers)
https://developers.facebook.com/docs/reference/api/user/
The only thing that worked for me was requesting for permitted fields through the API:
FB.api("/me", {fields: "email,..."}, callback)
This totally fixed the issue.
Hope that helps.