本文整理汇总了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;
}
示例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;
}