Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Sending private messages to Facebook users

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 408
    Comment on it

    Many of us have this requirement of sending private message to your facebook friends and we usally struggle to get it done. The main reason behind this is that graph api provided by facebook does not provide this. We have to look for other option which has been provided by facebook but facebook is really strict with it , if you ever try to spam a user your application might get blocked so please use it with care:

    Below is the ruby code which can be used to send message to friends ,gem being used for this is :

    And the code we need to send message is :

    sender_chat_id = "-#{sender_uid}"
    receiver_chat_id = "-#{receiver_uid}"
    message_body = "body of message you want to send"
    message_subject = "subject of message you want to send"
    jabber_message =, message_body)
    jabber_message.subject = message_subject
    client =
       ENV.fetch('FACEBOOK_APP_ID'), facebook_auth.token,
       ENV.fetch('FACEBOOK_APP_SECRET')), nil)

    *Note : Keep in mind that we have to add - infront of "-#{sender_uid}" else the code want work.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: