0
protected void ConnectToFaceBook_btn_Click(object sender, EventArgs e)
{
    string url = System.Uri.EscapeDataString("http://localhost:1298/FacebookChatApi/Default2.aspx");
    string clientID = "507061112747022";
    string redirecturl = @"https://graph.facebook.com/oauth/authorize?client_id="+clientID+"&redirect_uri="+url;
    Response.Redirect(redirecturl);

    GetAccessToken();
}

As you can see I am calling GetAccessToken() after Response.Redirect the given URL will return a query string called code and GetAccessToken. I am reading this query string but as I am doing it everything after Response.Redirect is not being executed. Is there any work around to call the redirecturl and get the code value without using Response.redirect?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Sora
  • 2,465
  • 18
  • 73
  • 146
  • Is the access token returned as a result of calling the URL? – NightOwl888 Feb 22 '14 at 19:48
  • no i get the authorization code when calling the redirecturl then inside getAccessToken i am reading the request["code"] – Sora Feb 22 '14 at 20:42
  • GteAccessToken should be in http://localhost:1298/FacebookChatApi/Default2.aspx not on your click event, basically, yuou send user to facebook, they login, facebook then redirects the user back to your website, on this page you then collect your token, your login button should not contain GetAcessToken, facebook will not be calling a click event on your button – davethecoder Mar 02 '14 at 23:21

1 Answers1

0

there is a program in linux,php,python and etc called curl that act like a browser in your program, curl in C# have some alternative that u can use them curl in C# have some alternative that u can use them.

Community
  • 1
  • 1
SdSaati
  • 798
  • 9
  • 18