Is there any way to post a Facebook application invite from Ruby on Rails, e.g. by deploying Koala?
Looks to be impossible at the glance. Any workarounds other than simply posting to a wall?
Actually mikeonrails gave a correct link - the Requests dialog is the way to invite friends to your app and send them other types of requests. It does require user interaction though (just as the video shows), for requests sent to users who don't have the application installed.
And now for the details. There are 2 types of requests that you can send:
user-generated requests: these can be sent to users who don't have the application installed (ie. application invite). They can only be sent using the Javascript SDK (or the iOS or Android SDKs but I don't think you're interested in those) and they do require user interaction. It will consist of a pop-up that will either display a selection (made by you) of his friends or a friend selector and a send button to send them your message.
app-generated requests: these can only be sent to users who have the application installed, but can be sent without user interaction.
The code for user-generated requests is like this (using the Javascript SDK):
// this will show the pop-up dialog with a friend selector
// add a `to: 'friend_id1,friend_id2` to skip the friend selector
FB.ui({
method: 'apprequests',
message: 'My Great Request'
}, requestCallback);
For the app-generated requests you can use Koala like this:
user = Koala::Facebook::API.new(user_token)
user.put_object("user_with_app_installed_id", "apprequests", {:message => "Would you like to be friends?")
So, the conclusion is that you cannot invite a user's friends to your application without his approval, but you can make it really simple for him to do it (2 clicks).
If you'd like to read more:
Requests Dialog: http://developers.facebook.com/docs/reference/dialogs/requests/
Social Channels: http://developers.facebook.com/docs/channels/#requests
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
UPDATE: Facebook chat API has been deprecated so it is not possible to use this solution anymore.
Related
How can I send mail on button action without using the stock iOS mail app?
var toAdress = "something#someting.com"
var fromAdress = "from#email.com"
var subject = "Something subject"
var message = "message text"
And i want to send using this info on buttonAction. Any API that does NOT use the stock IOS mail app?
If by “without using the stock iOS mail app” you mean send e-mail without switching to the Mail app, you can use MFMailComposeViewController to present an e-mail dialog within your app, and you can set the to, subject, and message fields for the user to edit (the “from” is the user's address).
If you mean without using this, then unless you are implementing an actual alternative e-mail client it seems very doubtful that you'd want to get into it. Sending e-mail is going to require user interaction and setup for the SMTP server, unless you control the mail server. And if you do control the mail server, you could quite simply set up a web API and make a http call to send the e-mail through your server (this would be suitable, e.g., if the intent is to let the user send you e-mail, or trigger an e-mail sent from you to the user).
How do I send a facebook app requests from one mobile user to another using the Graph API?
I have looked at facebooks documentation but the only options I have found are to A) send an app to user message from the app (which I can't get working) or B) to use the request dialog, which doesn't seem to let me send a request to a single user.
FB has instructions for how to build a custom "Multi-Friend Selector" but apparently not for mobile.
I have tried using HTTP POSTing to
https://graph.facebook.com/%s?access_token= ...
with POST data set to
message='Test Message'
but I get
WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "(#2) Failed to create any app request"
I have also tried in the Graph API Explorer but I get the same thing.
I don't want to send these messages to users that have installed the app and I don't mind the user having to provide confirmation for the FBFrictionlessRecipientCache. Also, my app is in Sandbox mode, but I only need to send the requests to the other developers.
I am looking for anything that will let me do multi-friend selectors or ask for lives, or get help from a friend, like I see in several mobile games these days.
You can use presentRequestsDialogModallyWithSession from FBWebDialogs.
You must specify a "to" parameter to identify the recipient, and you must use the FBFrictionlessRecipientCache.
The "to" parameter identifies the recipient. It stops the select user dialog from appearing.
The first time you send the request to each recipient the user will have to grant permission. After that, the FBFrictionlessRecipientCache will allow the request to be sent relatively silently (a dialog pops up briefly and goes away by itself).
I saw your post about sending messages to your Facebook friends via the IOS Facebook sdk,
I was wondering if there is a way to send a private message as well to these friends.
If not, is sending messages to your Facebook friends still supported from your previous post at:
iOS Development: How can I get a Facebook wall post to show in the friend's news feed?
If so let me know, thank you in advance
It is possible to send a private message via facebook- just not with the SDK. You can get the user's 'username' (ie. http://www.facebook.com/username) and you can send them an email via your app to 'username#facebook.com'.
Shapow!
Major bonus: attach a file and it will be included in the facebook message.
One caveat: the email will not reach the recipient's message inbox unless the sender's email address is affiliated with a valid facebook user account. I would imagine this is in place to thwart spam.
No, it is not possible to send private messages using the Graph API.
Yes, it is still possible to post to a friend's wall. I just checked it out just now using the graph API Explorer tool: http://developers.facebook.com/tools/explorer. I used /friendId/feed with an HTTP post of "message" = "testing" and my friend confirmed they saw it on their stream.
let messageDialouge = MessageDialog.init(content: <ShareContent>, delegate: nil)
if messageDialouge.canShow {
messageDialouge.show()
}
And do add fb-messenger-share-api inside the LSApplicationQueriesSchemes in info.plist
I saw your post about sending messages to your Facebook friends via the IOS Facebook sdk,
I was wondering if there is a way to send a private message as well to these friends.
If not, is sending messages to your Facebook friends still supported from your previous post at:
iOS Development: How can I get a Facebook wall post to show in the friend's news feed?
If so let me know, thank you in advance
It is possible to send a private message via facebook- just not with the SDK. You can get the user's 'username' (ie. http://www.facebook.com/username) and you can send them an email via your app to 'username#facebook.com'.
Shapow!
Major bonus: attach a file and it will be included in the facebook message.
One caveat: the email will not reach the recipient's message inbox unless the sender's email address is affiliated with a valid facebook user account. I would imagine this is in place to thwart spam.
No, it is not possible to send private messages using the Graph API.
Yes, it is still possible to post to a friend's wall. I just checked it out just now using the graph API Explorer tool: http://developers.facebook.com/tools/explorer. I used /friendId/feed with an HTTP post of "message" = "testing" and my friend confirmed they saw it on their stream.
let messageDialouge = MessageDialog.init(content: <ShareContent>, delegate: nil)
if messageDialouge.canShow {
messageDialouge.show()
}
And do add fb-messenger-share-api inside the LSApplicationQueriesSchemes in info.plist
I need to make the user able to send private message to his friends through facebook. In PHP there is something called Openinviter which can grab the contacts of nearly any social network or email provider.
I found a gem on rails called contacts that does the same thing for email providers. It can grab users friends from email providers but not social networks.
Is there a similar gem or plugin that I could use to make my application send private messages to facebook contacts?
Thanks,
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
No, sending private messages via email you've fetched from facebook's API or from a facebook app via the API seems to be against the current API TOS/Policies has in effect.