I can't send email to my app users, even though I have the permissions.
I am working with the java library, although I don't think it is related to that.
long uid = ...;
Collection<Long> uids = new ArrayList<Long>();
uids.add(uid);
FacebookXmlRestClient client = new FacebookXmlRestCli开发者_运维知识库ent(api, secret);
boolean sendEmailPerm = client.users_hasAppPermission(Permission.EMAIL,uid);
System.out.println("Can send email: "+ sendEmailPerm);
Collection<String> sent = client.notifications_sendTextEmail(uids, "subject", "body");
System.out.println("Succesfully sent email to: "+sent);
sent = client.notifications_sendFbmlEmail(uids, "subject", "body");
System.out.println("Succesfully sent email to: "+sent);
I am trying both with fbml and text email. I can also obtain the user's proxied_email property but when I send email to that address with my regular mail client is doesn't arrive.
The output is:
Can send email: true Succesfully sent email to: [] Succesfully sent email to: []
Is your application defined in the Facebook application settings as a Desktop App or a Web App?
If it is defined as a Desktop App you need to include a current valid Facebook session key for the user you are emailing. That could be what you are missing.
If the user is not logged in to your application/Facebook when you send the email, you will need to request the offline_access extended permission which lets you obtain and save a non-expiring "infinite" Facebook session key to use when sending the email.
I think that you never login successfully on Facebook or never create session correctly.
精彩评论