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


C# FacebookClient.SetJsonSerializers方法代码示例

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


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

示例1: CreateClient

 /// <summary>
 /// Creates a <see cref="FacebookClient"/> with AppId and AppSecret that uses Json.NET for serialization and deserialization.
 /// </summary>
 /// <returns>The <see cref="FacebookClient"/> instance.</returns>
 public virtual FacebookClient CreateClient()
 {
     FacebookClient client = new FacebookClient();
     client.AppId = _config.AppId;
     client.AppSecret = _config.AppSecret;
     client.SetJsonSerializers(JsonConvert.SerializeObject, JsonConvert.DeserializeObject);
     return client;
 }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:12,代码来源:DefaultFacebookClientProvider.cs

示例2: GetWebPosts

        private bool GetWebPosts()
        {
            _entities = new List<PostEntity>();
            using (var browser = new Browser())
            {
                try
                {
                    var redirectUrl = "http://www.mercenary.hu";
                    var clientID = "465962063448465";
                    var scope = "user_posts";
                    var navigationUrl = $"https://graph.facebook.com/oauth/authorize?client_id={clientID}&redirect_uri={redirectUrl}&scope={scope}&type=user_agent&display=popup";
                    browser.Open(navigationUrl);
                    var home = ModelFactory.GetModel<HomePage>();
                    home.Email = ConfigurationManager.AppSettings["UserEmail"];
                    home.Pass = ConfigurationManager.AppSettings["UserPass"];
                    home.Login();

                    var r = new Regex(@"#access_token=(.*)&expires_in=(.*)");
                    var accessToken = r.Match(browser.Uri.Fragment).Groups[1].Value;
                    _client = new FacebookClient(accessToken);
                    _client.SetJsonSerializers(JsonConvert.SerializeObject, JsonConvert.DeserializeObject);

                    //browser.Open("http://www.facebook.com/login.php");
                    //var home = ModelFactory.GetModel<HomePage>();
                    //home.Email = ConfigurationManager.AppSettings["UserEmail"];
                    //home.Pass = ConfigurationManager.AppSettings["UserPass"];
                    //home.Login();

                    var date = new DateTime(ToDate.Year, ToDate.Month, 1).AddMonths(1);
                    var userId = ConfigurationManager.AppSettings["UserId"];
                    do
                    {
                        date = date.AddMonths(-1);
                        browser.Open($"http://www.facebook.com/{userId}/timeline/{date.Year}/{date.Month}");
                        var timeline = ModelFactory.GetModel<TimelinePage>();
                        var c = timeline.PostCount;
                        bool changes;
                        do
                        {
                            var nc = c;
                            Context.Driver.ExecuteScript("window.scrollTo(0,document.body.scrollHeight);");
                            for (var i = 0; i < 5; i++)
                            {
                                Thread.Sleep(100);
                                nc = timeline.PostCount;
                                Debug.WriteLine("{0} {1} {2}", DateTime.Now, c, nc);
                                if (c != nc) break;
                            }
                            changes = c != nc;
                            c = nc;
                        } while (changes);

                        if (c == 0) continue;

                        foreach (var id in timeline.Posts.Select(p => p.TopLevelObjectId).Where(id => id != 0))
                        {
                            _workHandler.Run(() => GetPostDetails(id), GetPostDetailsCallback);
                        }
                    }
                    while (date > FromDate);
                }
                catch
                {
                    browser.SaveArtifacts();
                }
            }
            return true;
        }
开发者ID:mercenaryntx,项目名称:maxine,代码行数:68,代码来源:MainViewModel.cs


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