开发者

asp.net (C#) Facebook GetInfo()

I am struggling to get off with ground with some Facebook dev work. All I want to do is retireve some user info for the logged in user. This is the code I got from another site & it looks fine to me, however is always returns IsConnected() to be false.

I am running this code within an iframe on my facebook app (in sandbox mode)

private const string APPLICATION_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxx";
private const string SECRET_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxx";

public Facebook.Rest.Api Api;   
private Facebook.Session.ConnectSession _connectSession;   

protected void Page_Load(object sender, EventArgs e)
{

    _connectSession = new Facebook.Session.ConnectSession(APPLICATION_KEY,SECRET_KEY);

    if (!_connectSession.IsConnected())
    {
        lit.Text = "Please sign-in with Facebook.";
    }
    else
    {
        try
 开发者_C百科       {
            Api = new Facebook.Rest.Api(_connectSession);
            Facebook.Schema.user u = Api.Users.GetInfo();
            img.ImageUrl = u.pic_square;
            lit.Text = string.Format("Welcome, " + u.name);
        }
        catch (Exception ex)
        {
            lit.Text = ex.Message;
        }
    }
}


See this other SO question about a similar problem. The poster apparently found what he was looking for, but didn't know how to implement it. You may be able to do so, since there's a lot of information in the question body.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜