给朋友发私信

发布于 2024-08-27 19:35:31 字数 49 浏览 14 评论 0原文

我需要通过 Facebook 连接用户的信息并向他的所有朋友发送私人消息。是否可以?

I need to get via Facebook connect user's info and send a private message to all of his friends. Is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

眼角的笑意。 2024-09-03 19:35:31

现在可以通过 api 发送私人消息。

触发此事件以发送消息(facebook 对象的初始化应该在之前完成)。

to:user facebook

function facebook_send_message(to) {
    FB.ui({
        app_id:'xxxxxxxx',
        method: 'send',
        name: "sdfds jj jjjsdj j j ",
        link: 'https://apps.facebook.com/xxxxxxxaxsa',
        to:to,
        description:'sdf sdf sfddsfdd s d  fsf s '

    });
}

属性

  • 的 id

    app_id
    您的应用程序的标识符。必需,但自动指定
    大多数 SDK 都支持。

  • redirect_uri
    用户单击“发送”或“取消”后重定向到的 URL
    对话框上的按钮。必需的,但大多数人自动指定
    SDK。

  • 显示
    呈现对话框的显示模式。这是自动的
    大多数 SDK 都指定了。


  • 要将消息发送到的用户 ID 或用户名。一旦出现对话框
    出现时,用户可以指定其他用户、Facebook 群组,以及
    将消息发送到的电子邮件地址。将内容发送至
    Facebook 群组会将其发布到群组墙上。

  • 链接
    (必需)要在消息中发送的链接。

  • 图片
    默认情况下,将从指定的链接拍摄图片。网址
    要包含在消息中的图片。将显示图片
    在链接旁边。

  • 姓名
    默认情况下,将从指定的链接中获取标题。的名字
    链接,即用户将单击的要显示的文本。

  • 描述
    默认情况下,将从指定的链接获取描述。
    显示在链接下方的描述性文本。

查看更多此处

@VishwaKumar:

要发送带有自定义文本的消息,您必须将“message”参数添加到FB.ui,但我认为此功能已被弃用。您无法再预先填写消息。虽然尝试一次。

FB.ui({
  method: 'send',
  to: '1234',
  message: 'A request especially for one person.',
  data: 'tracking information for the user'
});

请参阅此链接:http://fbdevwiki.com/wiki/FB.ui

Sending private message through api is now possible.

Fire this event for sending message(initialization of facebook object should be done before).

to:user id of facebook

function facebook_send_message(to) {
    FB.ui({
        app_id:'xxxxxxxx',
        method: 'send',
        name: "sdfds jj jjjsdj j j ",
        link: 'https://apps.facebook.com/xxxxxxxaxsa',
        to:to,
        description:'sdf sdf sfddsfdd s d  fsf s '

    });
}

Properties

  • app_id
    Your application's identifier. Required, but automatically specified
    by most SDKs.

  • redirect_uri
    The URL to redirect to after the user clicks the Send or Cancel
    buttons on the dialog. Required, but automatically specified by most
    SDKs.

  • display
    The display mode in which to render the dialog. This is automatically
    specified by most SDKs.

  • to
    A user ID or username to which to send the message. Once the dialog
    comes up, the user can specify additional users, Facebook groups, and
    email addresses to which to send the message. Sending content to a
    Facebook group will post it to the group's wall.

  • link
    (required) The link to send in the message.

  • picture
    By default a picture will be taken from the link specified. The URL
    of a picture to include in the message. The picture will be shown
    next to the link.

  • name
    By default a title will be taken from the link specified. The name of
    the link, i.e. the text to display that the user will click on.

  • description
    By default a description will be taken from the link specified.
    Descriptive text to show below the link.

See more here

@VishwaKumar:

For sending message with custom text, you have to add 'message' parameter to FB.ui, but I think this feature is deprecated. You can't pre-fill the message anymore. Though try once.

FB.ui({
  method: 'send',
  to: '1234',
  message: 'A request especially for one person.',
  data: 'tracking information for the user'
});

See this link: http://fbdevwiki.com/wiki/FB.ui

清旖 2024-09-03 19:35:31

不,这是不可能的。为了让您向 Facebook 用户发送任何类型的消息,您需要获得该用户的许可。

如果有人通过 Facebook Connect 登录您的网站,则表示他们明确同意与您的网站共享其 Facebook 数据,然后您将能够通过正常渠道向该人发送消息。您还可以获取他们的朋友列表。但是,您无法向好友发送消息。

No, this isn't possible. In order for you to send messages of any kind to a Facebook user, you need that user's permission to do so.

If someone logs into your site with Facebook Connect, they are explicitly agreeing to share their Facebook data with your site, and you will then be able to send that person a message through the normal channels. You would also be able to fetch their friend list. However, you can not send messages to the friends.

ぺ禁宫浮华殁 2024-09-03 19:35:31

现在这是不可能的,但有一个解决方法。您可以在公共领域与用户互动并要求他们向您发送私人消息,但您不能发回私人消息,只能发回公共消息。当然,这一切都取决于用户是否授予您正确的权限。

如果您已授予访问某个人的朋友的权限,那么理论上您可以在该用户墙上发帖,引用每一位朋友,要求他们公开与您互动,然后可能向您私下发送消息。

获取朋友

#if authenticated
https://graph.facebook.com/me/friends
http://developers.facebook.com/docs/reference/api/user/

在公共领域的帖子

http://developers.facebook.com/docs/reference/api/status/

获取发送给该用户的消息(如果获得许可)

http://developers.facebook.com/docs/reference/api/message/

This is not possible now, but there is a work around. You can engage with the user in the public realm and ask them to send you private messages, but you can't send private messages back, only public ones. Of course, this all depends on if the user gives you the correct permissions.

If you have given permission to access a person's friends, you can then theoretically post on that users wall with references to each one of the friends, asking them to publicly interact with you and then potentially privately message you.

Get Friends

#if authenticated
https://graph.facebook.com/me/friends
http://developers.facebook.com/docs/reference/api/user/

Post in the Public Domain

http://developers.facebook.com/docs/reference/api/status/

Get Messages sent to that user (if given permission)

http://developers.facebook.com/docs/reference/api/message/
旧时模样 2024-09-03 19:35:31

您可以使用 Facebook Chat API 发送私人消息,下面是 Ruby 中使用 xmpp4r_facebook gem 的示例:

sender_chat_id = "-#{sender_uid}@chat.facebook.com"
receiver_chat_id = "-#{receiver_uid}@chat.facebook.com"
message_body = "message body"
message_subject = "message subject"

jabber_message = Jabber::Message.new(receiver_chat_id, message_body)
jabber_message.subject = message_subject

client = Jabber::Client.new(Jabber::JID.new(sender_chat_id))
client.connect
client.auth_sasl(Jabber::SASL::XFacebookPlatform.new(client,
   ENV.fetch('FACEBOOK_APP_ID'), facebook_auth.token,
   ENV.fetch('FACEBOOK_APP_SECRET')), nil)
client.send(jabber_message)
client.close

You can use Facebook Chat API to send private messages, here is an example in Ruby using xmpp4r_facebook gem:

sender_chat_id = "-#{sender_uid}@chat.facebook.com"
receiver_chat_id = "-#{receiver_uid}@chat.facebook.com"
message_body = "message body"
message_subject = "message subject"

jabber_message = Jabber::Message.new(receiver_chat_id, message_body)
jabber_message.subject = message_subject

client = Jabber::Client.new(Jabber::JID.new(sender_chat_id))
client.connect
client.auth_sasl(Jabber::SASL::XFacebookPlatform.new(client,
   ENV.fetch('FACEBOOK_APP_ID'), facebook_auth.token,
   ENV.fetch('FACEBOOK_APP_SECRET')), nil)
client.send(jabber_message)
client.close
甜是你 2024-09-03 19:35:31

一种解决方法(虽然不是很好)是使用新的 @facebook.com 电子邮件地址。这样做有一些缺点:

1)并非每个人(截至本文发布)都在其帐户中启用了新消息应用程序。

2) 并非每个人都会在消息应用程序中设置@facebook.com 电子邮件。

3) 并不是每个人都会选择他们的用户名(如果他们有 Facebook 用户名)作为他们的电子邮件地址。

One workaround, though not a great one, is to use the new @facebook.com email address. There are a few downsides to this:

1) Not everyone (as of this posting) has the new messages application enabled in their account.

2) Not everyone will have setup their @facebook.com email in their messages app.

3) Not everyone will choose their username (if they even have a facebook username) as their email address.

空袭的梦i 2024-09-03 19:35:31

你不能。 Facebook API 有 read_mailbox 但没有 write_mailbox 扩展权限。我猜这样做是为了防止垃圾邮件应用程序淹没朋友的收件箱。

You cannot. Facebook API has read_mailbox but no write_mailbox extended permission. I'm guessing this is done to prevent spammy apps from flooding friend's inboxes.

桃气十足 2024-09-03 19:35:31

对于移动应用程序,我通过在对话框视图中注入 javascript 做了一个解决方案。我的 ios 应用程序中有一个隐藏的网页视图。加载fb消息发送对话框api..然后我注入一些javascript来设置“to”和“message”字段并提交表单..这样最终用户不需要做任何事情。消息默默发送到 Facebook 收件箱...

For mobile application i did a solution by injecting javascript in the dialog view. There is a hidden web view in my ios app. That load the fb message send dialog api .. then i inject some javascript to set the "to" and "message" field and submit the form.. So that end user need not to do anything. Message sent to facebook inbox silently...

一场春暖 2024-09-03 19:35:31

这个帖子说你不能向 Facebook 上的一群朋友发送私人消息,但我发现了这个 https://developers.facebook.com/docs/sharing/reference/send-dialog

This thread says you can't do send private messages to a group of friends on facebook but I found this https://developers.facebook.com/docs/sharing/reference/send-dialog

水水月牙 2024-09-03 19:35:31

没有任何图形API,你需要使用facebook xmpp聊天api来发送消息,好消息是:我做了一个太容易使用的php类,调用一个函数并发送消息,它的开源,查看一下:facebook message api php 描述说它是闭源的,但后来开源了,请参阅第一条评论,您可以从 github 克隆。现在它是开源的。

There isn't any graph api for this, you need to use facebook xmpp chat api to send the message, good news is: I have made a php class which is too easy to use,call a function and message will be sent, its open source, check it out: facebook message api php the description says its a closed source but the it was made open source later, see the first comment, you can clone from github. It's a open source now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文