开发者

Post a private message to the user frined using Ruby and fb_graph gem?

I want to send a private message to a user's friend using fb_graph. In the docs I can see how to send a post in the users wall but n开发者_如何学Cot how to send a message on behalf of that user.


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


Unfortunately it cannot be done; Facebook removed the functionality due to abuse (spam etc).

Please refer to: how send message facebook friend through graph api using Accessstoken


It seems that is not possible but posting to the user's wall might be an alternative: https://github.com/nov/fb_graph/issues/issue/28/#comment_591398

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜