如何通过代码向 Facebook 好友发送电子邮件或消息
我一直在尝试阅读(剪切)有关通过代码向我的 Facebook 朋友发送消息或电子邮件的 Facebook 帖子丛林。 到目前为止我已经找到了 Facebook REST API: https://developers.facebook.com/docs/reference/rest/notifications .sendEmail/
使用测试工具进行测试时,它仅适用于向帐户发送邮件 您登录时使用的。不是已授予权限的帐户 应用。我为其他用户返回的信息是:
"error_code": 200,
"error_msg": "Permissions error",
"request_args": {...}
此 API 已弃用,将被 GRAPH API 取代: http://developers.facebook.com/docs/reference/api/
在这个API似乎没有发送任何电子邮件,但存在消息:
http://developers.facebook.com/docs/reference/api/message/
但这只允许阅读消息...... 发送内容的唯一方法是发布到用户墙上,即 我不想想做的事情。
所以我的问题是:
是否允许发送电子邮件或消息?
如果是,我该从哪里开始?我应该使用什么 API(JAVA)?
有没有办法通过 Janrain 做到这一点,我唯一发现的是 在墙上做吗?
额外问题 =)
- 为什么 Facebook 使查找相关信息变得如此困难?
****编辑*****
为了测试图形 API,我使用了位于 https: //developers.facebook.com/tools/explorer/ 。在那里,我输入了我的 Facebook ID 并执行了 GET:
https://graph.facebook.com/my.id
我得到的是有关我的帐户的一些信息,但没有电子邮件。
{
id: "mypersonalfacebookid",
name: "my name",
first_name: "my",
last_name: "name",
link: "http://www.facebook.com/my.name",
username: "my.name",
gender: "male",
locale: "en_US",
type: "user",
}
这没关系,因为我没有输入任何访问令牌。第二步是从 https://developers 输入我的应用程序的访问令牌。 facebook.com/apps,已授权用户 my.name 访问 my.name 的电子邮件:
我得到的回复:
{
id: "mypersonalfacebookid",
name: "my name",
first_name: "my",
last_name: "my name",
link: "http://www.facebook.com/my.name",
username: "my.name",
work: [
{
employer: {
id: "11111111111111",
name: "CooolCompany.com",
}
with: [
{
},
]
from: {
}
},
]
education: [
{
school: {
id: "11111111111",
name: "Studied Computer Science",
}
type: "College",
},
]
gender: "male",
email: "[email protected]",
timezone: 2,
locale: "en_US",
verified: true,
updated_time: "2011-07-20T17:12:26+0000",
type: "user",
}
很酷,电子邮件就在那里,但如果我为授予相同权限的其他用户执行此操作对于他/她的帐户:
{
id: "xxxxxx",
name: "My Friend",
first_name: "My",
last_name: "Friend",
link: "http://www.facebook.com/my.friend",
username: "my.friend",
hometown: {
id: "12345",
name: "Cool Town",
}
location: {
id: "1111111",
name: "Somewhere",
}
gender: "female",
locale: "en_US",
updated_time: "2011-06-29T19:21:38+0000",
type: "user",
}
这里没有电子邮件!为什么?
I've been trying read(cut) my way through the jungle of Facebook posts about sending a message or email to my Facebook friends through code.
So far I have found the Facebook REST API:
https://developers.facebook.com/docs/reference/rest/notifications.sendEmail/
When testing with the testing tool it only works sending mails to the account
that you are logged in with. Not the accounts that has granted permissions to the
application. All I'm getting back for the other users is:
"error_code": 200,
"error_msg": "Permissions error",
"request_args": {...}
This API is deprecated and will be replaced by the GRAPH API:
http://developers.facebook.com/docs/reference/api/
In this API it doesn't seem to be any email sending but message exist:
http://developers.facebook.com/docs/reference/api/message/
But that only allows reading messages...
The only way of sending things is to post to the users wall and that is
something that I do NOT want to do.
So my questions are:
Is it or will it be allowed to send emails or messages?
If yes where do I start? What API should I use(JAVA)?
Is there a way of doing this through Janrain, the only thing I found was
to do it on the wall?
Bonus question =)
- Why do Facebook make it so hard to find information about this?
****EDIT*****
To test Graph API I used the testing tool located at https://developers.facebook.com/tools/explorer/ . There I entered my facebook id and performed a GET:
https://graph.facebook.com/my.id
What I got back was some information about my account but no email
{
id: "mypersonalfacebookid",
name: "my name",
first_name: "my",
last_name: "name",
link: "http://www.facebook.com/my.name",
username: "my.name",
gender: "male",
locale: "en_US",
type: "user",
}
This is ok since i did not enter any Access Token. The second step was to enter the Access Token for my application from https://developers.facebook.com/apps, which has been granted for user my.name to access my.name's email:
What I got back:
{
id: "mypersonalfacebookid",
name: "my name",
first_name: "my",
last_name: "my name",
link: "http://www.facebook.com/my.name",
username: "my.name",
work: [
{
employer: {
id: "11111111111111",
name: "CooolCompany.com",
}
with: [
{
},
]
from: {
}
},
]
education: [
{
school: {
id: "11111111111",
name: "Studied Computer Science",
}
type: "College",
},
]
gender: "male",
email: "[email protected]",
timezone: 2,
locale: "en_US",
verified: true,
updated_time: "2011-07-20T17:12:26+0000",
type: "user",
}
Cool the email is there but if I do this for some other user that has granted the same privs for his/her account:
{
id: "xxxxxx",
name: "My Friend",
first_name: "My",
last_name: "Friend",
link: "http://www.facebook.com/my.friend",
username: "my.friend",
hometown: {
id: "12345",
name: "Cool Town",
}
location: {
id: "1111111",
name: "Somewhere",
}
gender: "female",
locale: "en_US",
updated_time: "2011-06-29T19:21:38+0000",
type: "user",
}
No email here! Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Q. 如何向 FB 用户发送电子邮件?
查看图形 API 浏览器:https://developers.facebook.com/tools/explorer/
C@脸书
Q. How to send an email to FB user?
Check out the graph API explorer: https://developers.facebook.com/tools/explorer/
C @ Facebook
首先,Facebook 让人们很难找到有关其 API 的信息,这绝对是不正确的。事实上,您可能会使用 REST API 自行调用此 API,因为该 API 已被标记为已弃用。
我建议您使用 GRAPH API,并阅读有关使用 OAuth 进行身份验证的信息。
在您的请求中,您必须请求执行其他操作的权限(标准权限除外)。我的猜测是您没有请求发送消息或电子邮件的许可。
First of all, it is absolutely not true that Facebook makes it hard to find information about their API's. In fact, you're probably calling this upon yourself by using the REST API, since that one has been marked as deprecated.
I would advise you to use the GRAPH API, and read up on authenticating using OAuth.
In your request, you have to ask for permission to do additional actions (other than the standard permissions). My guess is you're not asking for the permission to send a message or email.