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


C# FacebookClient.GetAsync方法代码示例

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


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

示例1: GetFriendsCount

        private object GetFriendsCount()
        {
            var fb = new FacebookClient(txtAccessToken.Text);
            //var fb = new FacebookClient();
            for (int i = 0; i < 100; i++) {
                dynamic result1 = fb.Get(i);
                string id = result1.id;
                string firstName = result1.first_name;
                var lastName = result1.last_name;
            }
            var query = string.Format("SELECT friend_count, name FROM user WHERE uid = me()");
            // var query1 = string.Format("SELECT uid,name,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})", "me()");
            fb.GetAsync("fql", new { q = query });
            object returnVal = 0;
            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                  //  Dispatcher.BeginInvoke();// () => MessageBox.Show(e.Error.Message));
                    return;
                }

                var result = (IDictionary<string, object>)e.GetResultData();
                var data = (IList<object>)result["data"];
                foreach (var comment in data.Cast<IDictionary<string, object>>())
                {
                    returnVal = comment["friend_count"];
                    // Dispatcher.BeginInvoke(() => MessageBox.Show(returnVal.ToString()));
                }

            };

            return returnVal;
        }
开发者ID:alsmadi,项目名称:FaceBook_NET,代码行数:34,代码来源:MainForm.cs

示例2: MyProfile

 // My facebook feed.
 internal void MyProfile()
 {
     GlobalContext.g_UserProfile = new UserProfile();
     var fb = new FacebookClient(GlobalContext.AccessToken);
     fb.GetCompleted +=
         (o, ex) =>
         {
             try
             {
                 var feed = (IDictionary<String, object>)ex.GetResultData();
                 GlobalContext.g_UserProfile.Name = feed["name"].ToString();
                 GlobalContext.g_UserProfile.UserID = feed["id"].ToString();
                 GlobalContext.g_UserProfile.Picture = (String)((IDictionary<String, object>)((IDictionary<String, object>)feed["picture"])["data"])["url"];
                 // GlobalContext.g_UserProfile.Picture = picture.data.url;
                 DBManager.getInstance().saveData(DBManager.DB_Profile, GlobalContext.g_UserProfile);
                 Deployment.Current.Dispatcher.BeginInvoke(delegate(){
                     App42Api.LinkUserFacebookAccount(LinkUserFacebookCallback);
                 });
             }
             catch (Exception e)
             {
                 MessageBox.Show(e.Message);
             }
         };
     var parameters = new Dictionary<String, object>();
     parameters["fields"] = "id,name,picture";
     fb.GetAsync("me", parameters);
 }
开发者ID:rahulpshephertz,项目名称:Platformer,代码行数:29,代码来源:MainPage.xaml.cs

示例3: LoadUserInfo

        /// <summary>
        /// Loads the user info.
        /// </summary>
        private void LoadUserInfo()
        {
            var fb = new FacebookClient(App.AccessToken);

            fb.GetCompleted += (sender, args) =>
            {
                if (args.Error != null)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
                    return;
                }

                var result = args.GetResultData<IDictionary<string, object>>();

                Dispatcher.BeginInvoke(() =>
                {
                    FacebookData.Me.Name = String.Format(
                        "{0} {1}",
                        (string)result["first_name"],
                        (string)result["last_name"]);

                    FacebookData.Me.PictureUri = new Uri(String.Format(
                        "https://graph.facebook.com/{0}/picture?type={1}&access_token={2}",
                        App.FacebookId,
                        "square",
                        App.AccessToken));
                });

                fb.GetAsync("me");
            };
        }
开发者ID:nntoanbkit,项目名称:yellow-cat,代码行数:34,代码来源:LandingPage.xaml.cs

示例4: LoginSucceded

        private void LoginSucceded(string accessToken)
        {
            var fb = new FacebookClient(accessToken);
            var are = new AutoResetEvent(false);
            Dispatcher.BeginInvoke(() => {
                NavigationService.Navigate(new Uri("/Connecting.xaml", UriKind.Relative));
                are.Set();
            });

            fb.GetCompleted += (o, e) => {
                if (e.Error != null) {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                    return;
                }

                var result = (IDictionary<string, object>)e.GetResultData();
                var id = (string)result["id"];

                Connection.FacebookUid = id;
                Connection.LoginType = 1;
                are.WaitOne();
                Dispatcher.BeginInvoke(() => Connection.Connect((Page) ((PhoneApplicationFrame)Application.Current.RootVisual).Content));
            };

            fb.GetAsync("me?fields=id");
        }
开发者ID:cloudsdaleapp,项目名称:cloudsdale-wp7,代码行数:26,代码来源:Login.xaml.cs

示例5: LoadUserInfo

        private void LoadUserInfo()
        {
            var fb = new FacebookClient(App.AccessToken);

            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                    return;
                }

                var result = (IDictionary<string, object>)e.GetResultData();

                Dispatcher.BeginInvoke(() =>
                {
                    //ProfileName.Text = "Hi " + (string)result["name"];
                    string myName = String.Format("{0} {1}", (string)result["first_name"], (string)result["last_name"]);
                    Uri myPictureUri = new Uri(string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", App.FacebookId, "square", App.AccessToken));

                    this.MyImage.Source = new BitmapImage(myPictureUri);
                    this.MyName.Text = myName;
                });
            };

            fb.GetAsync("me");
        }
开发者ID:kobeh207,项目名称:facebook-windows-phone-sample,代码行数:27,代码来源:LandingPage.xaml.cs

示例6: GetEventsList

        public void GetEventsList()
        {
            string fetchStr = string.Format(FetchString, ID);

            RFBClient = new FacebookClient(FBAuthenticationService.AccessToken);
            RFBClient.GetCompleted += new EventHandler<FacebookApiEventArgs>(OnGetEventsCompleted);
            RFBClient.GetAsync(fetchStr);
        }
开发者ID:AndrzejRPiotrowski,项目名称:Startups,代码行数:8,代码来源:FriendsEventsService.cs

示例7: myProfile

        // My facebook feed.
        public void myProfile()
        {
            var fb = new FacebookClient(_accessToken);
            fb.GetCompleted +=
                (o, ex) =>
                {

                    var feed = (IDictionary<string, object>)ex.GetResultData();
                    var me = feed["picture"] as JsonObject;
                    var pic = me["data"] as JsonObject;
                    string picture = pic["url"].ToString();
                    string name = feed["name"].ToString();
                    string id = feed["id"].ToString();
                    UpdateProfile(name, id, picture);
                    
                };

            var parameters = new Dictionary<string, object>();
            parameters["fields"] = "id,name,picture";
            fb.GetAsync("me", parameters);
        }
开发者ID:AjayTShephertz,项目名称:App42-Photo-Sharing,代码行数:22,代码来源:Util.cs

示例8: ProcessFbOathResult

        public bool ProcessFbOathResult(FacebookOAuthResult oauthResult)
        {
            var resultProcess = false;
            var accessToken = oauthResult.AccessToken;
            App.ViewModel.UserPreference.AccessKey = accessToken;
            var fbS = new FacebookClient(accessToken);

            fbS.GetCompleted += (o, res) =>
                                    {
                                        if (res.Error != null)
                                        {
                                            Dispatcher.BeginInvoke(() =>
                                                                       {
                                                                           gridFBLoggedIn.Visibility =
                                                                               Visibility.Collapsed;
                                                                           FaceBookLoginPage.Visibility =
                                                                               Visibility.Collapsed;
                                                                           LinkButton.Visibility = Visibility.Visible;
                                                                       });

                                            return;
                                        }

                                        var result = (IDictionary<string, object>) res.GetResultData();
                                        App.ViewModel.UserPreference.FbUserId = (string) result["id"];
                                        App.ViewModel.UserPreference.Name = (string) result["name"];
                                        App.ViewModel.LoadData(true);
                                        App.ViewModel.SaveSettings();
                                        Dispatcher.BeginInvoke(() =>
                                                                   {
                                                                       facebookImage.Source =
                                                                           App.ViewModel.UserPreference.UserImage;
                                                                       name.Text = App.ViewModel.UserPreference.Name;
                                                                   });
                                        resultProcess = true;
                                    };

            fbS.GetAsync("me");
            return resultProcess;
        }
开发者ID:peterdocter,项目名称:hydra,代码行数:40,代码来源:Settings.xaml.cs

示例9: FriendImages

        public List<string> FriendImages(ActivityItemsViewModel act)
        {
            if (App.ViewModel.UserPreference.AccessKey == null || act.FacebookId == null || act.FacebookId.Equals("") || !App.ViewModel.HasConnection)
                return null;
            var friends = new List<string>();
            var fb = new FacebookClient
            {
                AppId = App.ViewModel.Appid,
                AccessToken = App.ViewModel.UserPreference.AccessKey
            };
            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    return;
                }
                var result = (IDictionary<string, object>)e.GetResultData();
                var data = (IList<object>)result["data"];
                if (data.Count <= 0)
                {
                    return;
                }
                act.FriendsAttending = data.Count;
                for (var i = 0; i < 5; i++)
                {
                    var eventData = ((IDictionary<string, object>)data.ElementAt(i));
                    friends.Add((string)eventData["pic_square"]);
                }

            };
            var query = String.Format("SELECT pic_square FROM user WHERE uid IN"
            + "(SELECT uid2 FROM friend WHERE uid1 = me() AND uid2 IN"
            + "(SELECT uid FROM event_member WHERE eid = {0} "
            + "AND rsvp_status = 'attending'))", act.FacebookId);
             fb.GetAsync("fql", new { q = query });
            return friends;
        }
开发者ID:peterdocter,项目名称:hydra,代码行数:37,代码来源:ActivityItem.xaml.cs

示例10: LoginSucceded

        private void LoginSucceded(string accessToken)
        {
            var fb = new FacebookClient(accessToken);

            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                    return;
                }

                var result = (IDictionary<string, object>)e.GetResultData();
                SettingsManager.FacebookActive = true;
                SettingsManager.FacebookToken = accessToken;
                SettingsManager.FacebookId = (string)result["id"];

                Dispatcher.BeginInvoke(() => {
                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                });
            };

            fb.GetAsync("me?fields=id");
        }
开发者ID:alexcons,项目名称:MyMovies,代码行数:24,代码来源:FacebookLoginPage.xaml.cs

示例11: LoadUserInfo

        private void LoadUserInfo()
        {


            var fb = new FacebookClient(fftoken);

            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                    return;
                }

                var result = (IDictionary<string, object>)e.GetResultData();

                Dispatcher.BeginInvoke(() =>
                {
                    var profilePictureUrl = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}&width=150&height=150", ffid, "square", fftoken);

                    this.user_image.Source = new BitmapImage(new Uri(profilePictureUrl));
                    //this.MyName.Text = String.Format("{0} {1}", (string)result["first_name"], (string)result["last_name"]);
                });
            };

            fb.GetAsync("me");
        }
开发者ID:NSemaX,项目名称:ShareToAll_WindowsPhone,代码行数:27,代码来源:MainPivot.xaml.cs

示例12: FqlAsyncExample

        private void FqlAsyncExample()
        {
            var fb = new FacebookClient(_accessToken);

            // since FQL is internally a GET request,
            // make sure to add the GET event handler.
            fb.GetCompleted += (o, e) =>
            {
                // incase you support cancellation, make sure to check
                // e.Cancelled property first even before checking (e.Error!=null).
                if (e.Cancelled)
                {
                    // for this example, we can ignore as we don't allow this
                    // example to be cancelled.

                    // you can check e.Error for reasons behind the cancellation.
                    var cancellationError = e.Error;
                }
                else if (e.Error != null)
                {
                    // error occurred
                    this.BeginInvoke(new MethodInvoker(
                                                 () =>
                                                 {
                                                     MessageBox.Show(e.Error.Message);
                                                 }));
                }
                else
                {
                    // the request was completed successfully

                    // now we can either cast it to IDictionary<string, object> or IList<object>
                    // depending on the type. or we could use dynamic.
                    var result = (IDictionary<string, object>)e.GetResultData();
                    var data = (IList<object>)result["data"];

                    var count = data.Count;

                    // since this is an async callback, make sure to be on the right thread
                    // when working with the UI.
                    this.BeginInvoke(new MethodInvoker(
                                         () =>
                                         {
                                             lblTotalFriends.Text = string.Format("You have {0} friend(s).", count);
                                         }));
                }
            };

            // query to get all the friends
            var query = string.Format("SELECT uid,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})", "me()");

            // call the Query or QueryAsync method to execute a single fql query.
            fb.GetAsync("fql", new { q = query });
        }
开发者ID:jjooeellkkaarrrr,项目名称:facebook-winforms-sample,代码行数:54,代码来源:InfoDialog.cs

示例13: FqlSample

        /// <summary>
        /// Fql Sample to get Result
        /// </summary>
        public void FqlSample()
        {
            var fb = new FacebookClient(_accessToken);

            fb.GetCompleted += (o, args) =>
                                   {
                                       if (args.Error != null)
                                       {
                                           Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
                                           return;
                                       }

                                       var result = (IDictionary<string, object>) args.GetResultData();
                                       var data = (IList<object>) result["data"];

                                       // since this is an async callback, make sure to be on the right thread
                                       // when working with the UI.
                                       Dispatcher.BeginInvoke(() =>
                                                                  {
                                                                      txtAnswer.Text = data.ToString();
                                                                  });
                                   };

            // query to get all the friends
            var query =string.Format("SELECT uid,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})","me()");
            fb.GetAsync("fql", new {q = query});
        }
开发者ID:pankajc-optimus,项目名称:windows-lib,代码行数:30,代码来源:InfoPage.xaml.cs

示例14: LoadUserInformation

        /// <summary>
        /// Load Facebook information of the user
        /// </summary>
        public void LoadUserInformation()
        {
            // available picture types: square (50x50), small (50xvariable height), large (about 200x variable height) (all size in pixels)
            string profilePictureUrl = string.Format(
                "https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", _userId, "square", _accessToken);
            // load profile picture
            picProfile.Source = new BitmapImage(new Uri(profilePictureUrl));

            var fb = new FacebookClient(_accessToken);
            fb.GetCompleted += (o, e) =>
                                   {
                                       if (e.Error != null)
                                       {
                                           Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                                           return;
                                       }

                                       var result = (IDictionary<string, object>) e.GetResultData();
                                       Dispatcher.BeginInvoke(() =>
                                                                  {
                                                                      ProfileName.Text = "Hi " + (string) result["name"];
                                                                      FirstName.Text = "First Name: " +
                                                                                       (string) result["first_name"];
                                                                      FirstName.Text = "Last Name: " +
                                                                                       (string) result["last_name"];
                                                                  });
                                   };

            // get user information
            fb.GetAsync("me");
        }
开发者ID:pankajc-optimus,项目名称:windows-lib,代码行数:34,代码来源:InfoPage.xaml.cs

示例15: GetComments

        private void GetComments(String photoID,String URL)
        {
            String comments = "";
            var fb = new FacebookClient(_accessToken);
            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                    return;
                }
                var result = (IDictionary<string, object>)e.GetResultData();

                Dispatcher.BeginInvoke(() =>
                {
                    int min=2;
                    IList data = (IList)result["data"];
                    if (data.Count < 2)
                        min = data.Count;
                    for (int i = 0; i < min; i++)
                    {
                        IDictionary<string, object> entry = (IDictionary<string, object>)data[i];
                        IDictionary<string, object> from = (IDictionary<string, object>)entry["from"];
                        comments = comments + (string)from["name"] + ": ";
                        comments = comments + (string)entry["message"]+ " ";
                    }
                    if (comments == "")
                        comments = "No comments. Tap to open in facebook and comment there.";
                    HubTile hubtile = (HubTile)this.FindName(URL);
                    hubtile.Message = comments;

                });
            };
            fb.GetAsync(photoID + "/comments?limit=2&fields=from,message");
        }
开发者ID:bhargavgolla,项目名称:WindowsPhoneApps,代码行数:35,代码来源:MainPage.xaml.cs


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