当前位置: 首页>>代码示例>>C#>>正文


C# FacebookClient.Query方法代码示例

本文整理汇总了C#中Facebook.FacebookClient.Query方法的典型用法代码示例。如果您正苦于以下问题:C# FacebookClient.Query方法的具体用法?C# FacebookClient.Query怎么用?C# FacebookClient.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook.FacebookClient的用法示例。


在下文中一共展示了FacebookClient.Query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SingleQuery

        public static void SingleQuery(string accessToken)
        {
            var query = string.Format("SELECT uid,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})", "me()");

            try
            {
                var fb = new FacebookClient(accessToken);

                var result = (IList<object>)fb.Query(query);

                foreach (var row in result)
                {
                    var r = (IDictionary<string, object>)row;
                    var uid = (long)r["uid"];
                    var picSquare = (string)r["pic_square"];

                    Console.WriteLine("User Id: {0}", uid);
                    Console.WriteLine("Picture Square: {0}", picSquare);
                    Console.WriteLine();
                }

                // Note: This json result is not the orginal json string as returned by Facebook.
                Console.WriteLine("Json: {0}", result.ToString());
            }
            catch (FacebookApiException ex)
            {
                // Note: make sure to handle this exception.
                throw;
            }
        }
开发者ID:rehabriad,项目名称:MyNokat,代码行数:30,代码来源:FQL.cs

示例2: MultiQuery

        public static void MultiQuery(string accessToken)
        {
            var query1 = "SELECT uid FROM user WHERE uid=me()";
            var query2 = "SELECT profile_url FROM user WHERE uid=me()";

            try
            {
                var fb = new FacebookClient(accessToken);

                var result = (IList<object>)fb.Query(query1, query2);

                var result0 = ((IDictionary<string, object>)result[0])["fql_result_set"];
                var result1 = ((IDictionary<string, object>)result[1])["fql_result_set"];

                Console.WriteLine("Query 0 result: {0}", result0);
                Console.WriteLine();
                Console.WriteLine("Query 1 result: {0}", result1);
                Console.WriteLine();

                // Note: This json result is not the orginal json string as returned by Facebook.
                Console.WriteLine("Json: {0}", result.ToString());
            }
            catch (FacebookApiException ex)
            {
                // Note: make sure to handle this exception.
                throw;
            }
        }
开发者ID:rehabriad,项目名称:MyNokat,代码行数:28,代码来源:FQL.cs

示例3: GetUser

 /// <summary>
 /// gets the Application User representation of "me"
 /// </summary>
 /// <param name="i_AccessToken"></param>
 /// <returns></returns>
 public static ApplicationUser GetUser(string i_AccessToken)
 {
     ApplicationUser result = new ApplicationUser();
     FacebookClient fbClient = new FacebookClient(i_AccessToken); ;
     dynamic me = fbClient.Query(
      "SELECT uid, name, first_name, last_name, pic_small, pic_big, pic_square, pic, email, birthday_date FROM user WHERE uid = me()");
     result = createUserFromDynamicUser(me[0], result);
     result.AccessToken = i_AccessToken;
     return result;
 }
开发者ID:yoavzurel,项目名称:Facebook-Utilities,代码行数:15,代码来源:FacebookUtilities.cs

示例4: GetUsersFriends

        /// <summary>
        /// return a dictionary of users friends. sorted as {ID,FRIEND}
        /// </summary>
        /// <param name="i_AccessToken"></param>
        /// <returns></returns>
        public static Dictionary<string, Friend> GetUsersFriends(string i_AccessToken)
        {
            Dictionary<string, Friend>  result = new Dictionary<string, Friend>();
            FacebookClient fbClient = new FacebookClient(i_AccessToken);

            dynamic userFriends = fbClient.Query(
             "SELECT uid, name, first_name, last_name, pic_small, pic_big, pic_square, pic, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())");
            foreach (dynamic friend in userFriends)
            {
                Friend tempFriend = new Friend();
                createUserFromDynamicUser(friend, tempFriend);
                result.Add(tempFriend.Id, tempFriend);
            }

            return result;
        }
开发者ID:yoavzurel,项目名称:Facebook-Utilities,代码行数:21,代码来源:FacebookUtilities.cs

示例5: GetPicUrls

        private static void GetPicUrls(List<string> queries, ConcurrentBag<Uri> picsToGet, string seconds,
            string queryFormat)
        {
            Parallel.ForEach(Settings.Default.FacebookUsersSettings.UserSettings,
                             (userSetting =>
                                  {
                                      string[] ids = userSetting.PictureSettings.Select(x => x.User.Id).ToArray();
                                      string query = string.Format(queryFormat, string.Join(",", ids), seconds);
                                      queries.Add(query);
                                      var fb = new FacebookClient(userSetting.AccessToken);
                                      dynamic result = fb.Query(query);

                                      foreach (dynamic pic in result)
                                      {
                                          picsToGet.Add(new Uri(pic.src_big));
                                      }
                                  }));
        }
开发者ID:scottccoates,项目名称:SoPho,代码行数:18,代码来源:MainWindow.xaml.cs

示例6: SearchForFacebookId

 private void SearchForFacebookId(int personId, string firstname, string surname, FacebookClient client)
 {
     try
     {
         string fullname = firstname + " " + surname;
         dynamic friends = client.Query("SELECT uid, first_name, last_name FROM user WHERE uid IN (    SELECT uid2    FROM friend    WHERE uid1=me()) AND name='" + fullname + "'");
         if (friends.Count == 1)
         {
             PersonDataAccessor.SavePersonFacebookId(personId, friends[0].uid);
         }
     }
     catch { }
 }
开发者ID:rodown,项目名称:funwithoiky,代码行数:13,代码来源:AjaxController.cs


注:本文中的Facebook.FacebookClient.Query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。