通过vb.net应用程序登录 [英] facebook login via vb.net application
问题描述
我计划创建一个vb.net应用程序,该应用程序将与用户的Facebook帐户同步。我想创建一个应用程序,允许用户通过此vb.net应用程序登录他们的帐户,获取通知,朋友请求,查看/回复/创建消息以及要从Facebook获取的其他活动。
我的问题是我不知道从哪里开始。我的意思是,我需要学习如何创建履带或什么东西?什么API,SDK我必须学习这个?哪里最好的地方开始?有没有讨论这些东西的网站或文章?
感谢您的见解!
我不是专家,但我已经做了一个
并阅读它在thig上的工作方式博客文章。它是C#,但您应该能够轻松地在VB.Net中重现它。
不要忘记编辑 AppId
字符串并编写自己的密钥!
public partial class Form1:Form
{
private const string AppId =APP KEY;
private const string ExtendedPermissions =user_about_me,read_stream;
private string _accessToken;
[...]
}
一旦您添加了 App Key
,就可以运行该程序。点击登录后,它会打开一个小的webBrowser控件,让您登录到Facebook。正确的登录过程返回 facebookOAuthResult
对象,其中包含您的 AccessToken
。
当您实例化 FacebookClient
时,您必须通过您的 AccessToken
,该类将用于您的请求。在这种情况下,您只需获取您的身份信息,并从webrequest的结果(即 JSON $ c $)中获取您的
名称
c $格式)
private void DisplayAppropriateMessage(FacebookOAuthResult facebookOAuthResult)
{
if(facebookOAuthResult!= null)
{
if(facebookOAuthResult.IsSuccess)
{
_accessToken = facebookOAuthResult.AccessToken;
var fb = new FacebookClient(facebookOAuthResult.AccessToken);
动态结果= fb.Get(/ me);
var name = result.name;
// for .net 3.5
// var result =(IDictionary< string,object>)fb.Get(/ me);
// var name =(string)result [name];
MessageBox.Show(嗨+名称);
btnLogout.Visible = true;
}
else
{
MessageBox.Show(facebookOAuthResult.ErrorDescription);
}
}
}
要测试您的查询飞行,您可以使用 Graph API Explorer 。
我想这足以开始!祝你好运
I am planning to create a vb.net application that will be synchronized with user's facebook account. I want to create an application that allows the user to login their accounts, fetch notifications, friend requests, view/reply/create messages and other activities they want to fetch from facebook via this vb.net application.
My problem is I don't have any idea where to start. I mean, do I need to learn how to create crawler or something? What API's, SDK's do I have to study for this? Where is the best place to start? Are there any websites or articles that are discussing these kind of things also?
Thank you for insights!
I'm not an expert but I've done a small project in C#
You should start installing the Facebook SDK from NuGet and reading some documentation on https://developers.facebook.com/ The registration on Facebook Developers is mandatory to receive to get your App Key
Getting an App Key:
- https://developers.facebook.com/apps
- Register
Create New App. Choose some unique
App Name
Once you've created your app, you get your
App ID
key.
Back to Visual Studio - Creating your .Net Project
I strongly suggest you download this working project FB-CSharp-SDK-First-FB-Application and read how it works on thig blog post. It is C# but you should be able to easily reproduce it in VB.Net.
Don't forget to edit AppId
string and write your own key!
public partial class Form1 : Form
{
private const string AppId = "APP KEY";
private const string ExtendedPermissions = "user_about_me,read_stream";
private string _accessToken;
[...]
}
Once you added your App Key
you can run the program. Upon clicking "Login" it'll open a small webBrowser control that let you login into facebook. The correct login procedure returns a facebookOAuthResult
Object that contains your AccessToken
.
You must pass your AccessToken
when you instantiate FacebookClient
, the class that you will use for your requests. In this case you're simply getting your identity information and get your name
from the result of the webrequest (that is in JSON
format).
private void DisplayAppropriateMessage(FacebookOAuthResult facebookOAuthResult)
{
if (facebookOAuthResult != null)
{
if (facebookOAuthResult.IsSuccess)
{
_accessToken = facebookOAuthResult.AccessToken;
var fb = new FacebookClient(facebookOAuthResult.AccessToken);
dynamic result = fb.Get("/me");
var name = result.name;
// for .net 3.5
//var result = (IDictionary<string, object>)fb.Get("/me");
//var name = (string)result["name"];
MessageBox.Show("Hi " + name);
btnLogout.Visible = true;
}
else
{
MessageBox.Show(facebookOAuthResult.ErrorDescription);
}
}
}
To test your queries on the fly, you can use Graph API Explorer.
I guess it's enough to start! Good Luck
这篇关于通过vb.net应用程序登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!