首先,我會注意到:
搜索API將返回結果的全球跨Google+搜索。無法通過程序化方式閱讀Google+信息流(例如,用戶在訪問plus.google.com時看到的內容)。此外,您只能檢索公開的活動。
這就是說,當你檢索活動喂,你在做什麼,你可以通過活動循環,並找到附件的那些如下:
String nextPageToken = "";
do
{
ActivitiesResource.SearchRequest req = ps.Activities.Search("awesome");
req.PageToken = nextPageToken;
ActivityFeed feed = req.Fetch();
nextPageToken = feed.NextPageToken;
for (int i = 0; i < feed.Items.Count; i++)
{
if (feed.Items[i].Object.Attachments != null)
{
// the activity has associated content you can retrieve
var attachments = feed.Items[i].Object.Attachments;
}
}
}while(nextPageToken != null);
另一種方法是使用Activities.list方法列出連接到當前授權用戶的人員列表。您將執行一個people.list請求,以查看當前用戶的已連接人員,然後列出他們的公共Feed「
// Get the PeopleFeed for the currently authenticated user.
PeopleFeed pf = ps.People.List("me", PeopleResource.CollectionEnum.Visible).Fetch();
String nextPageToken = "";
for(int personIndex = 0; personIndex < pf.Items.Count; personIndex++)
{
ActivitiesResource.ListRequest req = ps.Activities.List(pf.Items[personIndex].Id, ActivitiesResource.Collection.Public);
req.PageToken = nextPageToken;
ActivityFeed feed = req.Fetch();
nextPageToken = feed.NextPageToken;
for (int i = 0; i < feed.Items.Count; i++)
{
if (feed.Items[i].Object.Attachments != null)
{
// the activity has associated content you can retrieve
var attachments = feed.Items[i].Object.Attachments;
}
}
}