本文整理汇总了C#中YouTubeRequest.GetActivities方法的典型用法代码示例。如果您正苦于以下问题:C# YouTubeRequest.GetActivities方法的具体用法?C# YouTubeRequest.GetActivities怎么用?C# YouTubeRequest.GetActivities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YouTubeRequest
的用法示例。
在下文中一共展示了YouTubeRequest.GetActivities方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YouTubeUserActivitiesTest
public void YouTubeUserActivitiesTest()
{
Tracing.TraceMsg("Entering YouTubeUserActivitiesTest");
YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey);
// settings.PageSize = 15;
YouTubeRequest f = new YouTubeRequest(settings);
List<string> users = new List<string>();
users.Add("whiskeytonsils");
users.Add("joelandberry");
// this returns the server default answer
Feed<Activity> feed = f.GetActivities(users);
foreach (Activity a in feed.Entries)
{
VerifyActivity(a);
}
// now let's find all that happened in the last 24 hours
DateTime t = DateTime.Now.AddDays(-1);
// this returns the all activities for the last 24 hours default answer
try
{
Feed<Activity> yesterday = f.GetActivities(users, t);
foreach (Activity a in yesterday.Entries)
{
VerifyActivity(a);
}
}
catch (GDataNotModifiedException e)
{
Assert.IsTrue(e != null);
}
t = DateTime.Now.AddMinutes(-1);
// this returns the all activities for the last 1 minute, should be empty or throw a not modified
try
{
Feed<Activity> lastmin = f.GetActivities(users, t);
int iCount = 0;
foreach (Activity a in lastmin.Entries)
{
iCount++;
}
Assert.IsTrue(iCount == 0, "There should be no activity for the last minute");
}
catch (GDataNotModifiedException e)
{
Assert.IsTrue(e != null);
}
}
示例2: UpdateActivities
private void UpdateActivities()
{
this.refreshTimer.Enabled = false;
DateTime since = DateTime.MinValue;
if (this.allActivities.Count == 0)
{
// first call, do a modified-since query
since = DateTime.Now.AddHours(-1 * this.initialPullinHours);
}
int iCounter = 0;
this.nIcon.BalloonTipText = "";
List<string> users = GetUserNames();
if (users.Count > 0 && String.IsNullOrEmpty(users[0]) != true)
{
// let's see if we get a valid authtoken back for the passed in credentials....
YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTubeNotifier",
YTCLIENTID,
YTDEVKEY);
// settings.PageSize = 15;
YouTubeRequest r = new YouTubeRequest(settings);
Feed<Activity> pf = r.GetActivities(users, since);
iCounter += ProcessFeed(pf, since);
}
if (this.authToken != null)
{
Feed<Activity> f = this.ytRequest.GetActivities(since);
iCounter += ProcessFeed(f, since);
}
// now redo the layout in the right order of controls:
this.linkList.SuspendLayout();
this.linkList.Controls.Clear();
foreach (Activity act in this.allActivities)
{
LinkLabel l = new LinkLabel();
string when = act.Updated.ToShortDateString();
if (act.Updated.Date == DateTime.Now.Date)
{
// it happened today
when = act.Updated.ToShortTimeString();
}
if (act.Updated.Date == DateTime.Now.AddDays(-1).Date)
{
when = "yesterday, at " + act.Updated.ToShortTimeString();
}
l.Text = act.Author + " has ";
bool noLink = false;
int len = 5;
switch (act.Type)
{
case ActivityType.Commented:
l.Text += "commented on ";
len = AddVideoText(l, act.VideoId);
break;
case ActivityType.Favorited:
l.Text += "favorited ";
len = AddVideoText(l, act.VideoId);
break;
case ActivityType.FriendAdded:
l.Text += "added a friend - " + act.Username ;
noLink = true;
break;
case ActivityType.Rated:
l.Text += "rated ";
len = AddVideoText(l, act.VideoId);
break;
case ActivityType.Shared:
l.Text += "shared ";
len = AddVideoText(l, act.VideoId);
break;
case ActivityType.SubscriptionAdded:
l.Text += "subscriped to " + act.Username;
noLink = true;
break;
case ActivityType.Uploaded:
l.Text += "uploaded ";
len = AddVideoText(l, act.VideoId);
break;
}
l.AutoSize = true;
//.........这里部分代码省略.........
示例3: YouTubeRequestActivitiesTest
public void YouTubeRequestActivitiesTest() {
Tracing.TraceMsg("Entering YouTubeRequestActivitiesTest");
YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);
YouTubeRequest f = new YouTubeRequest(settings);
// this returns the server default answer
Feed<Activity> feed = f.GetActivities();
foreach (Activity a in feed.Entries) {
Assert.IsTrue(a.VideoId != null, "There should be a VideoId");
}
// now let's find all that happened in the last 24 hours
DateTime t = DateTime.Now.AddDays(-1);
// this returns the all activities for the last 24 hours
try {
Feed<Activity> yesterday = f.GetActivities(t);
foreach (Activity a in yesterday.Entries) {
Assert.IsTrue(a.VideoId != null, "There should be a VideoId");
}
} catch (GDataNotModifiedException e) {
Assert.IsTrue(e != null);
}
t = DateTime.Now.AddMinutes(-1);
// this returns the all activities for the last 1 minute, should be empty or throw a not modified
try {
Feed<Activity> lastmin = f.GetActivities(t);
int iCount = 0;
foreach (Activity a in lastmin.Entries) {
iCount++;
}
Assert.IsTrue(iCount == 0, "There should be no activity for the last minute");
} catch (GDataNotModifiedException e) {
Assert.IsTrue(e != null);
}
}