Esempio n. 1
0
        public FacebookProfilModel GetUserInfo(dynamic accessToken)
        {
            //Kullanıcı bilgilerini çektiğimiz metod.

            var     client  = new FacebookClient(accessToken);
            var     profile = new FacebookProfilModel();
            dynamic me      = client.Get("/me?fields=id,cover,name,first_name,last_name,age_range,link,gender,locale,email,location");

            /*
             * ,cover,name,first_name,last_name,age_range,link,gender,locale,email,location
             * "/me" yerine kullanıcının Facebook ID'sini de yazabilirsiniz."me"
             * o anki kullanıcıyı temsil etmektedir.Yani değişen birşey yok.
             *
             */

            profile.kullanici_adi = me.name;
            profile.isim          = me.first_name;
            profile.soyisim       = me.last_name;
            profile.Id            = me.id;
            profile.Email         = me.email;
            profile.yas           = me.age_range.min.ToString();
            profile.link          = me.link;
            if (me.location != null)
            {
                FaceBookEntity fe = new FaceBookEntity();
                fe.Id       = me.location.id;
                fe.Adi      = me.location.name;
                profile.Yer = fe;
            }
            profile.locale      = me.locale;
            profile.Cinsiyet    = me.gender;
            profile.ProfilResmi = string.Format("http://graph.facebook.com/{0}/picture", profile.Id);
            return(profile);
        }
Esempio n. 2
0
 public void FacebookProfil(string code)
 {
     if (code != null)
     {
         string              state  = "";
         string              type   = "";
         dynamic             token  = Face.GetAccessToken(code, state, type);
         FacebookProfilModel Profil = Face.GetUserInfo(token);
         if (site_islem.BireyselKayitOlKontrol(Profil.Email))
         {
             FormsAuthentication.SetAuthCookie(Profil.Email, true);
             Session["giris_yapan"] = Profil.Email;
             if (Session["oturum_sonrasi_sayfa"] != null)
             {
                 Response.Redirect(Session["oturum_sonrasi_sayfa"].ToString());
             }
             else
             {
                 Response.RedirectToRoute("Home");
             }
             return;
         }
         string resimadi = "Eduadvisor-uye-" + DateTime.Now.ToString("ddMMyyyyHHmmssffff");
         try
         {
             WebClient            wc        = new WebClient();
             byte[]               bytes     = wc.DownloadData(string.Format("http://graph.facebook.com/{0}/picture", Profil.Id));
             MemoryStream         ms        = new MemoryStream(bytes);
             System.Drawing.Image img       = System.Drawing.Image.FromStream(ms);
             string               extension = "";
             if (ImageFormat.Jpeg.Equals(img.RawFormat))
             {
                 extension = ".jpg";
             }
             else if (ImageFormat.Png.Equals(img.RawFormat))
             {
                 extension = ".png";
             }
             resimadi += extension;
             if (!extension.Equals(""))
             {
                 img.Save("C:/Inetpub/vhosts/eduadvisor.co.uk/httpdocs/Content/img/kul_profil/" + resimadi);
             }
             else
             {
                 resimadi = "profil.png";
             }
         }
         catch (Exception)
         {
             resimadi = "profil.png";
         }
         string sonuc = site_islem.BireyselKayitOl(Profil.isim, Profil.soyisim, resimadi, Profil.Email, islem.randomSifreUret(), true, 0);
         if (sonuc.Equals("1") || sonuc.Equals("-9"))
         {
             FormsAuthentication.SetAuthCookie(Profil.Email, true);
             Session["giris_yapan"] = Profil.Email;
         }
     }
     if (Session["oturum_sonrasi_sayfa"] != null)
     {
         Response.Redirect(Session["oturum_sonrasi_sayfa"].ToString());
     }
     else
     {
         Response.RedirectToRoute("Home");
     }
 }