本文整理汇总了C#中IUserSession.GetTrendsForPlace方法的典型用法代码示例。如果您正苦于以下问题:C# IUserSession.GetTrendsForPlace方法的具体用法?C# IUserSession.GetTrendsForPlace怎么用?C# IUserSession.GetTrendsForPlace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserSession
的用法示例。
在下文中一共展示了IUserSession.GetTrendsForPlace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTrendsTest
public async Task<bool> DoTrendsTest(IUserSession session, List<int> testSeq)
{
var successStatus = true;
var trendToSearch = "";
int woeidToSearch = 1;
try
{
// 1
if (testSeq.Contains(1))
{
//-33.884097,151.134796
ConsoleOutput.PrintMessage("8.1 Trends\\GetTrendsByLocation", ConsoleColor.Gray);
var trends1 = await session.GetTrendsByLocation(latitude:-33.884097,longitude:151.134796);
if (trends1.OK)
{
foreach (var trnd in trends1)
{
ConsoleOutput.PrintMessage(
String.Format("Name: {0} // Url: {1}", trnd.Name, trnd.Url));
woeidToSearch = trnd.WOEID;
}
}
else
successStatus = false;
}
// 2
if (testSeq.Contains(2))
{
ConsoleOutput.PrintMessage("8.2 Trends\\GetTrendsForPlace as specified in location", ConsoleColor.Gray);
var trends2 = await session.GetTrendsForPlace(placeId: woeidToSearch);
if (trends2.OK)
{
foreach (var trnd in trends2.ToList()[0].trends)
{
ConsoleOutput.PrintMessage(
String.Format("Trend: {0} // Query: {1}", trnd.name, trnd.query));
trendToSearch = trnd.query;
}
}
else
successStatus = false;
ConsoleOutput.PrintMessage("8.2.1 Search\\SearchFor from Trend", ConsoleColor.Gray);
var trends21 = await session.SearchFor(trendToSearch, SearchResultType.Popular, count: 20 );
if (trends21.OK)
{
foreach (var tweet in trends21.Tweets)
{
ConsoleOutput.PrintMessage(
String.Format("From: {0} // Message: {1}", tweet.User.ScreenName, tweet.Text));
}
}
else
successStatus = false;
}
}
catch (Exception e)
{
ConsoleOutput.PrintError(e.ToString());
return false;
}
return successStatus;
}