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.
Related
I'm trying to implement the following solution: a web application that subscribes to all MS teams chat messages. If a message contains forbidden text, the application should somehow warn the user (Ideally by replying to the same message, or, if not possible, initiate a conversation with the user).
I'm able to receive all chat webhooks and process them, but I could not find any way to post a message back to the Teams channel using the Graph API (the operation described in https://learn.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-beta&tabs=http
is not supported for Application permissions - only delegated ones which isn't suitable for our case).
So I'm trying to send proactive messages using the Bot framework, However, the bot framework requires a teams conversation ID which I don't have (the graph API webhook provides the team, channel and user IDs, none of which are accepted by the Bot API).
Does anyone know of a way I can retrieve the teams conversation ID using the team ID and channel ID provided by the graph API?
Thanks,
Dan
ConversationId for channel messages are combination of channelId and messageId both can be found in payload you get webhook notification. You can reply to existing conversation by using following by building converstionId like this:
conversationId = $"{channelId};messageid={messageId}"
For reply to work, your Bot needs to installed in the team and should have serviceURL saved at some place to refer back. Here is sample code which show how you can reply to existing message.
var serviceURL = "YOUR Service URL- You get this in each bot payload";
MicrosoftAppCredentials.TrustServiceUrl(serviceURL, DateTime.MaxValue);
using var connector = new ConnectorClient(new Uri(serviceURL, MicrosoftAppId, MicrosoftAppPassword);
var conversationId = $"{channelId};messageid={messageId}";
var replyActivity = MessageFactory.Text($"This is simple reply to existing conversation.");
replyActivity.Conversation = new ConversationAccount(id: conversationId);
var response = await connector.Conversations.SendToConversationAsync(conversationId, replyActivity);
For 1:1 reply- please take a look at Sending Proactive Message documentation.
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).
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
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.
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