Using FbGraph API for private messaging
hiii i am new user of fbgraph api. I want to send private message to my friends using that api. i have seen some sites that are sending messages using facebook messaging api. can i use the same? Or is there any alternative to send private messages? Are there 开发者_如何学Pythonany limitation? please guide me about this. Thank you
You can't use the Graph API for sending private messages, but you can use the send dialog:
http://developers.facebook.com/docs/reference/dialogs/send/
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
I tried the xmpp4r_facebook gem / Jabber approach and it works fine.
Problem is that if you send a link to your site and it contains the Open Graph meta tags info, they don't get loaded so you've got a beautiful logo and share message put in place, such as:
<meta property="fb:app_id" content="1234567890"/>
<meta property="og:title" content="GreatApp"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://greatapp.com"/>
<meta property="og:image" content="http://greatapp.com/logo.jpg"/>
<meta property="og:site_name" content="GreatApp"/>
<meta property="og:description" content="The Greatest App Ever"/>
and this get's loaded when you use the Facebook send private message UI manually though seinding it over the Facebook chat either manually or via the approach above, this info isn't taken into account which ruins the whole user experience for sending invites.
I'll try other approaches.
I think IT IS NOW supported by Graph API. https://developers.facebook.com/docs/reference/api/message/
精彩评论