asp.net通过服务器端api登录facebook [英] asp.net login to facebook via server side api

查看:70
本文介绍了asp.net通过服务器端api登录facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

如果我有用户的电子邮件和密码,我如何实施httpwebrequest登录到facebook?

有人可以给我发送代码示例吗?



从下面的评论中复制的其他信息

我使用facebook SDK。我尝试了很多不同的方向。我在网上搜索了很多关于这个主题的文章并找到了。我在DotNetOpenAuth上看到了一些例子。

这是我的代码示例:

Hello,
how can i implement httpwebrequest login to facebook if i have the user email and password?
can somebody send me code sample?

additional information copied from comment below
I work with facebook SDK. I tried a lot of different directions. I searched online quite a few articles on the subject and found. I've seen examples on DotNetOpenAuth.
This is my code sample:

var auth = new CanvasAuthorizer { Permissions = new[] { "user_about_me", "publish_stream", "video_upload", "share_item", "photo_upload", "offline_access" } };

            var fbWebContext = FacebookWebContext.Current;
            if (fbWebContext.IsAuthorized())
            {
                try
                {
                    var fb = new FacebookWebClient(fbWebContext);
                  //  var token = fb.AccessToken;  // Im Getting Token This Way When its Generated From User After Getting Extended Permission
                  //  dynamic result = fb.Get("/me");
                    long id = fbWebContext.UserId;
                }
                catch (Exception ex)
                {
                    if ("(OAuthException) Error validating access token: The session is invalid because the user logged out or because auth.expireSession was invoked." == ex.Message)
                    {
                        fbWebContext.DeleteAuthCookie();
                        Session.Clear();
                    }
                }
            }



i没有访问令牌 - 我应该在登录


i dont have the access token - I should get it after sign in

推荐答案

这不是CP通常的工作方式。这里最重要的目标是学习和帮助学习。

你应该自己尝试,当你遇到困难时来到这里,对你的代码,设计等有一个具体的问题。

请查看你有什么尝试? [ ^ ]至看看我的意思是一个很好的解释。

不要忘记这里的人不会得到报酬。此外,如果我们为您提供随时可用的解决方案,它将不会帮助您,因为您不会从中学到任何东西。





另一方面......你检查过 http://developers.facebook.com/ [< a href =http://developers.facebook.com/target =_ blanktitle =New Window> ^ ]?您可能会找到相关信息。
This is not how CP usually works. Most important goal here is to learn and help learning.
You are supposed to try it on your own, and come here when you got stuck with something, with a concrete question about your code, design, etc.
Please have a look to What have you tried?[^] to see a good explanation about what I mean.
Don't forget people here don't get payed. And besides, if we give you a ready-to-go solution, it is not going to help you because you are not going to learn anything from it.


On the other hand... have you checked http://developers.facebook.com/[^]? You might find relevant information.


这篇关于asp.net通过服务器端api登录facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆