I use Facebook Connect for login on my website and need to create functionality of sending personal messages to user's Facebook friends.
A solution from this question is not suitable for me because I need to send messages to several friends at the same time (user just selects friends from the list who she/he wants to send a message).
I've found pretty good post about this question for Ruby - How to send private messages with Facebook API. But I can't find a C# package similar to xmpp4r_facebook Ruby gem.
agsXMPP SDK and jabber-net don't support X-FACEBOOK-PLATFORM SASL mechanism (http://forum.ag-software.de/thread/1372-Facebook-Chat and Connect to facebook chat using Jabber.net (C#/Mono) with SASL).
I hope to find some existing solution instead of updating one of these libraries. Or to find some library like xmpp4r_facebook but for .NET platform.
Thanks.
The latest sources of agsXMPP supports the X-FACEBOOK-PLATFORM Sasl mechanism.
1) checkout the latest sources
2) add the following code to the OnSaslStart event
private void XmppCon_OnSaslStart(object sender, SaslEventArgs args)
{
args.Mechanism = Mechanism.GetMechanismName(agsXMPP.protocol.sasl.MechanismType.X_FACEBOOK_PLATFORM);
args.ExtentedData = new FacebookExtendedData {AccessToken = "YOUR TOKEN", ApiKey = "YOUR API KEY"};
}
Facebook does not allow the SDK to send private messages to prevent misuse by spammers
Related
I am trying to create a client-side Discord Bot that can read my private messages and respond to them automatically. For example, if someone sends me the message "ping" in my DMs, the bot would reply with "pong". I am looking to create this bot using C#, but I am not sure where to start or if there are any specific tools or libraries that would be helpful for this task.
I have done some research and found a lot of information on how to create Discord Bots using Python, but most of it relates to creating server-side bots, not client-side ones like I am looking to do.
I am having difficulty finding information specifically on how to create a client-side Discord Bot that can read private messages and respond to them automatically. Any guidance or advice on how to accomplish this would be greatly appreciated.
You can do it using discord.py library for python. Just create simple event listener and send DM to a user with given ID like this:
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client()
#client.event
async def on_message(message):
if message.content == "help me":
user = client.get(YOUR_ID) # specify your Discord account ID here
if user is not None:
await user.send("Hi someone needs help")
client.run("TOKEN")
Trying to check if a User has the ManageServer Permission. I've already got the DiscordClientId & DiscordGuildId and the below is designed to get the current users permissions and from there I can specify the permission I'm looking for, but I can't figure it out
var user = userClientId;
var server = guildId;
var userServerPermissions = server.GetPermissions(user);
EDIT: I'm using a HttpWebRequest to get the DiscordClientId and GuildId's for the user when they login via Oauth2, then splitting out the various data I need to get the Id's.
I strongly recommend that you look into using a library for doing this. The one I've always used is Discord.NET, the library you mentioned on your question with the discord.net tag. Another C# discord library I'm aware of is DSharpPlus but I've never tried it.
For Discord.NET I suggest using the nightly/preview versions because they incorporate the recent Discord intents change. Use them by adding https://www.myget.org/F/discord-net/api/v3/index.json to your Nuget package sources.
A library handles everything nicely for you, meaning that you never need to directly send requests to or receive requests from Discord. Read the Discord.NET getting started guide here.
Here's code from Discord.NET which will determine if some user in some guild has the ManageServer permission:
public bool HasManageServerPermission(SocketGuildUser user)
{
return user.GuildPermissions.ManageGuild;
}
I have a chatbot which is built in Microsoft bot framework with Node.js and I integrated this bot with a NLP framework called LUIS.AI as well. I am integrating it with Skype and Messenger and also trying to integrate it with WeChat. I am trying to use following link for WeChat integration but not yet able to do it.
https://github.com/jyfcrw/botbuilder-wechat-connector and https://github.com/markusf/botbuilder-wechat
Is there any other documentation or example for WeChat channel integration?
After doing more research i found that we can use DirectLine3.0 to connect to the WeChat backend. There is not an official channel yet.
Here are some useful links:
http://aihelpwebsite.com/Blog/EntryId/16/Calling-The-Microsoft-Bot-Framework-Using-The-Direct-Line-API
https://github.com/leonlj/BotDemo
I had just published a BotBulider Connector that supports Wechat PERSONAL Account at here:
GitHub: https://github.com/zixia/botbuilder-wechaty-connector
NPM: https://www.npmjs.com/package/botbuilder-wechaty-connector
It will be easy to use because you only need to scan the QR code to log in instead of register an official account with APP_ID & APP_SECRET.
Code Example
import * as builder from 'botbuilder'
import { WechatyConnector } from 'botbuilder-wechaty-connector'
// Create wechat personal account connector
const wechatyConnector = new WechatyConnector()
const bot = new builder.UniversalBot(wechatyConnector)
bot.dialog('/', [/* ... */])
wechatyConnector.listen()
See More
In case you are interesting more, here's a blog post I had just wrote: Integrate Wechat Personal Account to Microsoft BotFramework with a BotBuilder Wechaty Connector
With Twitter's new OAuth interface, their API is now many times more complex than what it was. And I haven't even looked at Facebook's API yet.
What I'm wondering if there is a method that employs some higher-level, existing code or interfaces to make this a simpler task.
All I want to be able to do is initiate a Twitter tweet or Facebook share on the user's behalf and be able to control the initial text of those messages, from an ASP.NET application.
I found some similar questions on SO, but they had no answers.
EDIT: I know there are things like AddThis and ShareThis, but I need something that will give me control over the default message. It must contain a link with a code that is specific to the current user.
Twitter Integration...
For making Tweets from an ASP.NET application on users' behalf, check out Twitterizer. It's a free, open-source project for integrating with Twitter from .NET applications.
I agree that using OAuth can be a bit daunting, but the Twitterizer API wraps up most of the complexity. I've written an article on using Twitterizer in an ASP.NET application that you may be interested in: Integrating Twitter Into An ASP.NET Website Using OAuth. After reading the article, download the code sample at the end, which is a working demo showing how to use Twitterizer to post a tweet from an ASP.NET website.
Facebook Integration...
For integrating with Facebook, chcek out the Facebook Developer Toolkit. Like Twitterizer, it's an open-source, free API and should get you going in the right direction.
Happy Programming!
After looking around for a while, I found sharethis.com. They have various share buttons you can add to your site that send Twitter tweets, Facebook shares, etc.
It looks like it also supports options to control the URL, so I could modify this to include whatever URL I need.
I haven't yet figured out if I can control the default message text. I'm looking into that.
But it seems like this is probably the simplest way to accomplish what I want.
This is probably what you're after for twitter: https://twitter.com/about/resources/buttons#tweet
Let's you configure a button (or URL to redirect to) that starts the user off with some default text. The user can change the text before they post.
Don't know about facebook.
Twitter Integration:
Check this code and link/article simple and easy :
protected void btnTweet_Click(object sender, EventArgs e)
{
string oauthAccessToken = Session["twtoken"].ToString();
string oauthAccessTokenSecret = Session["twsecret"].ToString();
OAuthHelper oauthhelper = new OAuthHelper();
oauthhelper.TweetOnBehalfOf(oauthAccessToken, oauthAccessTokenSecret, txtTweet.Text);
if (string.IsNullOrEmpty(oauthhelper.oauth_error))
Response.Write("Twit Posted Successfully");
else
Response.Write(oauthhelper.oauth_error);
}
Read more how to get access token and secret key and download OAuthHelper and OAuthUtility Class below is the link -
How to post tweet on behalf of an user from asp.net using oauth authentication
Login with twitter using oauth authentication in asp.net and get access token, screen name and userid
i want to develop Desktop based application in wpf (c#). which will need option to login their facebook account too. so i have registered my app in fb developer site and download C# sdk with reference some stack overflow link. which always give connection failed
// code which i have used
string APIKey = ConfigurationManager.AppSettings["API_Key"];
string APISecret = ConfigurationManager.AppSettings["API_Secret"];
Facebook.Session.ConnectSession connectsession = new Facebook.Session.ConnectSession(APIKey, APISecret);
if (connectsession.IsConnected())
{
Facebook.Rest.Api api = new Facebook.Rest.Api(connectsession);
var friends = api.Friends.GetLists();
foreach (var friend in friends)
{
System.Console.WriteLine(friend.name);
}
}
some site telling that C# sdk is deprecated.
http://developers.facebook.com/blog/post/624/
Facebook Graph C# SDK Ver 6.0: Unable to create event on App's Page
please help me to start facebook api integration in my desktop based app using wpf. some body asked to use graph api but i have doubt whether this will supprot for c# . am struk to start my step on facebook integration.
Graph Api is fully supported in C# because it is based on rest and you can call rest service through C# code, obviously url calling is different from method calling, In graph api you can call url and parse its response. I would recommend to go with graph api, Facebook has not provided the C# SDK, its a open source library maintained by open source community, however graph api help is directly provided by Facebook.
Check here and here to know how to call graph api through C#