facebook:为什么我无法从应用程序向用户发送电子邮件?

fly*_*ire 2 java facebook

即使我拥有权限,也无法向我的应用用户发送电子邮件.

我正在使用java库,虽然我认为它与此无关.

long uid = ...;
Collection<Long> uids = new ArrayList<Long>();
uids.add(uid);
FacebookXmlRestClient client = new FacebookXmlRestClient(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);
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用fbml和文本电子邮件.我也可以获取用户的proxied_email属性,但是当我用常规邮件发送电子邮件到该地址时,客户端无法到达.

输出是:

Can send email: true
Succesfully sent email to: []
Succesfully sent email to: []

Pat*_*mes 6

您的应用程序是在Facebook应用程序设置中定义为桌面应用程序还是Web应用程序?

如果将其定义为桌面应用程序,则需要为要通过电子邮件发送的用户包含当前有效的Facebook会话密钥.那可能就是你所缺少的.

如果用户在您发送电子邮件时未登录到您的应用程序/ Facebook,则需要请求offline_access扩展权限,以便您在发送电子邮件时获取并保存未过期的"无限"Facebook会话密钥.