public FacebookQuerier(string accessToken) { mFacebookClient = new FacebookClient(accessToken); mFacebookDataContext = new FacebookDataContext(mFacebookClient); }
private void FqlToLinqSample() { var fb = new FacebookClient(GetAccessToken()); var db = new FacebookDataContext(fb); var useQuerySyntax = true; var useMethodSyntax = false; if (useQuerySyntax) { /* var albumQuery = from album in db.Album where album.Aid == new AlbumId("20531316728_324257") select album; var albumResult = albumQuery.ToArray(); var applicationQuery = from application in db.Application where application.AppId == new AppId("231464590266507") // servicestack-dev || application.Namespace == "skype" // Skype || application.Namespace == "inthemafia" // Mafia Wars || application.Namespace == "m_calendar" // MyCalendar select application; var applicationResult = applicationQuery.ToArray(); var apprequestQuery = from apprequest in db.Apprequest where apprequest.RecipientUid == db.Me && apprequest.AppId == new AppId("231464590266507") select apprequest; var apprequestResult = apprequestQuery.ToArray(); var checkinQuery = from checkin in db.Checkin where checkin.AuthorUid == db.Me select checkin; var checkinResult = checkinQuery.ToArray(); var albumObjectIdQuery = from album in db.Album where album.Aid == new AlbumId("20531316728_324257") select album.ObjectId; var commentQuery = from comment in db.Comment where albumObjectIdQuery.Contains(comment.ObjectId) select comment; var commentResult = commentQuery.ToArray(); var connectionQuery = from connection in db.Connection where connection.SourceId == db.Me select connection; var connectionResult = connectionQuery.ToArray(); var cookiesQuery = from cookies in db.Cookies where cookies.Uid == db.Me select cookies; var cookiesResult = cookiesQuery.ToArray(); var developerQuery = from developer in db.Developer where developer.DeveloperId == db.Me select developer; var developerResult = developerQuery.ToArray(); var eventQuery = from event_ in db.Event where event_.Eid == new EventId("209798352393506") select event_; var eventResult = eventQuery.ToArray(); var commentsQuery = from comments in db.Comment where comments.ObjectId == new ObjectId("483854529708") select comments; var commentsResult = commentsQuery.ToArray(); var threadQuery = from thread in db.Thread where thread.FolderId == FolderId.Inbox select thread.ThreadId; var messageQuery = from message in db.Message where threadQuery.Contains(message.ThreadId) select message; var messageResult = messageQuery.ToArray(); DateTime yesterday = DateTime.Today.AddDays(-1); var threadQuery2 = from thread in db.Thread where thread.FolderId == FolderId.Inbox select thread.ThreadId; var messageQuery2 = from message in db.Message where threadQuery2.Contains(message.ThreadId) && message.CreatedTime > yesterday select message; var messageResult2 = messageQuery2.ToArray(); var notificationQuery = from notification in db.Notification where notification.RecipientId == db.Me select notification; var notificationResult = notificationQuery.ToArray(); var groupQuery = from group_ in db.Group where group_.Gid == new GroupId("146797922030397") select group_; var groupResult = groupQuery.ToArray(); var streamQuery = from stream in db.Stream where stream.SourceId == db.Me select stream; var streamResult = streamQuery.ToArray(); //*/ // substr sample //var friendIds = from friend in db.Friend where friend.Uid1 == db.Me select friend.Uid2; //var friendDetails = (from user in db.User where friendIds.Contains(user.Uid) && user.Name.Substring(0, 1) == "a" select new { Uid = user.Uid, Name = user.Name, Picture = user.PicSmall }); // strlen sample //var friendIds = from friend in db.Friend where friend.Uid1 == db.Me select friend.Uid2; //var friendDetails = (from user in db.User where friendIds.Contains(user.Uid) && user.Name.Length == 14 select new { Uid = user.Uid, Name = user.Name, Picture = user.PicSmall }); // strpos sample //var friendIds = from friend in db.Friend where friend.Uid1 == db.Me select friend.Uid2; //var friendDetails = (from user in db.User where friendIds.Contains(user.Uid) && user.Name.IndexOf("as") > 0 select new { Uid = user.Uid, Name = user.Name, Picture = user.PicSmall }); var friendIds = from friend in db.Friend where friend.Uid1 == db.Me select friend.Uid2; var friendDetails = (from user in db.User where friendIds.Contains(user.Uid) select new { Uid = user.Uid, Name = user.Name, Picture = user.PicSmall }); listFriends.DataSource = friendDetails.ToArray(); DataBind(); } else if (useMethodSyntax) { var friendIds2 = db.Friend.Where(t => t.Uid1 == db.Me).Select(t => t.Uid2); var friendDetails2 = db.User.Where(t => friendIds2.Contains(t.Uid)).Select(t => new { Name = t.Name, Picture = t.PicSmall }).Take(5); listFriends.DataSource = friendDetails2.ToArray(); DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { GridView1.PageIndexChanging += GridView1_PageIndexChanging; string prefix = ConfigurationManager.AppSettings["mode"]; string mRedirectUri = ConfigurationManager.AppSettings[prefix + "_redirectUri"]; string clientId = ConfigurationManager.AppSettings[prefix + "_clientId"]; string clientSecret = ConfigurationManager.AppSettings[prefix + "_clientSecret"]; FacebookAuthentication auth = new FacebookAuthentication(clientId, clientSecret, mRedirectUri); string accessToken = auth.Login(Request.Params["code"]); var fb = new FacebookClient(accessToken); db = new FacebookDataContext(fb); if (!IsPostBack) { QueryFriendList(); QueryLinks(); } }