Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            lblStep1.Visible = false;
            FbLoginBrowser dlg = new FbLoginBrowser();

            dlg.ExtendedPermissions.Add("read_stream");
            dlg.ExtendedPermissions.Add("friends_birthday");
            dlg.ExtendedPermissions.Add("friends_status");
            dlg.ExtendedPermissions.Add("friends_education_history");
            dlg.ExtendedPermissions.Add("friends_relationships");

            dlg.AppId = FbApp.ApplicationKey;
            dlg.ShowDialog();

            if (dlg.Success)
            {
                app = new FacebookApp(dlg.AccessToken);
                var     result  = app.Get("me");
                JObject jobject = JObject.Parse(result.ToString());
                tsStatusMessage.Text = string.Format("Connected as {0}", jobject["name"]);
                me.Name   = (string)jobject["name"];
                me.Gender = (string)jobject["gender"];

                btnGetFriends.Enabled = true;
                btnConnect.Enabled    = false;
                lblStep1.Visible      = true;
            }
            else
            {
                tsStatusMessage.Text = string.Format("FAILED to connect: {0}", dlg.ErrorReason);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            lblStep1.Visible = false;
            FbLoginBrowser dlg = new FbLoginBrowser();
            dlg.ExtendedPermissions.Add("read_stream");
            dlg.ExtendedPermissions.Add("friends_birthday");
            dlg.ExtendedPermissions.Add("friends_status");
            dlg.ExtendedPermissions.Add("friends_education_history");
            dlg.ExtendedPermissions.Add("friends_relationships");

            dlg.AppId = FbApp.ApplicationKey;
            dlg.ShowDialog();

            if (dlg.Success)
            {
                app = new FacebookApp(dlg.AccessToken);
                var result = app.Get("me");
                JObject jobject = JObject.Parse(result.ToString());
                tsStatusMessage.Text = string.Format("Connected as {0}", jobject["name"]);
                me.Name = (string)jobject["name"];
                me.Gender = (string)jobject["gender"];

                btnGetFriends.Enabled = true;
                btnConnect.Enabled = false;
                lblStep1.Visible = true;

            }
            else
                tsStatusMessage.Text = string.Format("FAILED to connect: {0}", dlg.ErrorReason);
        }