1

Facebookタブをクリックしてゲームをプレイしても認証メッセージが表示されないという奇妙なことがありましたが、ゲームをサーバーに配置したゲームのURLをコピーする必要があり、認証メッセージが表示され、クリックすると認証できますFacebookタブはうまく機能します。何が間違っているのですか?

ここに画像の説明を入力

Facebook_ログインページ

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        string host = System.Configuration.ConfigurationManager.AppSettings["host"];
        string facebookClientId =
          System.Configuration.ConfigurationManager.AppSettings["FacebookClientId"];
        string RedirectURL = "http://facebookapp.elarabygroup.com";
        if (Request.QueryString["redirectURL"] != null)
        {
            RedirectURL = Request.QueryString["redirectURL"].ToString();
            Session["RedirectURL"] = RedirectURL;
        }
        Response.Redirect(@"https://graph.facebook.com/oauth/authorize?client_id=" +
          facebookClientId + "&redirect_uri=http://" + host +
          @"/FBcallback.aspx&scope=publish_stream,offline_access,publish_actions");
    }
}

FBcallback ページ

protected void Page_Load(object sender, EventArgs e)
{

    if (Request.QueryString["code"] != null)
    {

        string facebookClientId = System.Configuration.ConfigurationManager.AppSettings["FacebookClientId"];
        string facebookSecret = System.Configuration.ConfigurationManager.AppSettings["FacebookSecret"];
        string host = System.Configuration.ConfigurationManager.AppSettings["host"];
        string code = Request.QueryString["code"];

        var url = 
            string.Concat("https://graph.facebook.com/oauth/access_token?client_id=" + facebookClientId,"&redirect_uri=http://" + host + "/admin/facebook/auth.aspx","&client_secret=" + facebookSecret,"&code=" + code);

        oAuthFacebooks fbAC = new oAuthFacebooks();
        string respnse = "";
        try
        {
            fbAC.AccessTokenGet(code);
            respnse = fbAC.Token;
        }
        catch (Exception ex)
        {
            Response.Redirect("http://x/SiteLogin.aspx?error=" + ex.Message);
        }

        if (Session["RedirectURL"] != null && Session["RedirectURL"].ToString() != "")
        {
            Response.Redirect(Session["RedirectURL"].ToString() + "?token=" + respnse + "&source=FB");
        }
        else
        {
            Response.Redirect("http://x/SiteLogin.aspx?token=" + respnse);
        }

    }
    else
    {
        Response.Redirect("http://x/SiteLogin.aspx?error=code not found" +
                       Request.QueryString["error_reason"].ToString());
    }

}

サイトログインページ

if (Request.QueryString["token"] != null)
    {
        string token = Request.QueryString["token"];

        string PostURL = string.Format("https://graph.facebook.com/me?access_token={0}", token);
        oAuthFacebooks objFbCall = new oAuthFacebooks();
        string JSONInfo = objFbCall.WebRequest(oAuthFacebooks.Method.GET, PostURL, "");

        JObject Job = JObject.Parse(JSONInfo);
        JToken Jdata = Job.Root;

        //added from other soluation
       // string code = Request.QueryString["code"];

        if (Jdata.HasValues)
        {
            //added from other soluation
            /*string data = FaceBookConnect.Fetch(code, "me");
            FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);*/

            string UID = (string)Jdata.SelectToken("id");
            string firstname = (string)Jdata.SelectToken("first_name");
            string lastname = (string)Jdata.SelectToken("last_name");

            string pic = string.Format("https://graph.facebook.com/{0}/picture", UID);


            string username = firstname + " " + lastname;

           userdata.Attributes.Add("Value", "fb_id="+UID+ "&fb_name="+username+"&fb_img=" + pic);
           userdata2.Attributes.Add("Value", "fb_id=" + UID + "&fb_name=" + username + "&fb_img=" + pic);


        }

    }
    else

    { Response.Write(" xx"); }
}
4

1 に答える 1