views:

337

answers:

2

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 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);

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: []
+5  A: 

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.

Pat James
That answer should be much more higher in google result... 2h of life just wasted... but anyway thx a lot ;) +1
Rin
A: 

i thinks that you never login successfully on facebook or never create session correct

show me your full code on [email protected]

Khoyendra Pande