G+;域API谷歌应用程序脚本公共帖子扫描
我正在运行一个脚本,该脚本扫描我们的域用户G+帖子,并标记任何公开共享的帖子,然后向最终用户发送带有帖子链接的电子邮件通知。剧本是由不再在公司工作的其他人写的。我想更改脚本,以便它将标记任何没有G+;域API谷歌应用程序脚本公共帖子扫描,api,google-apps-script,google-plus,Api,Google Apps Script,Google Plus,我正在运行一个脚本,该脚本扫描我们的域用户G+帖子,并标记任何公开共享的帖子,然后向最终用户发送带有帖子链接的电子邮件通知。剧本是由不再在公司工作的其他人写的。我想更改脚本,以便它将标记任何没有“domainRestricted”的帖子;正确 function checkPublicPosts( userId ) { var publicPosts = Array(); var pageToken; try { do { Logger.log( 'Sca
“domainRestricted”的帖子;正确
function checkPublicPosts( userId ) {
var publicPosts = Array();
var pageToken;
try {
do {
Logger.log( 'Scanning posts by ' + userId );
// Search for all Google Plus posts by userId
posts = PlusDomains.Activities.list( userId, 'user', {
maxResults: 100,
pageToken: pageToken
});
// If posts are found, check to see if they are public
if( posts.items ) {
for( var i = 0; i < posts.items.length; i++ ) {
var post = posts.items[i];
var public = false;
if( !post.access.domainRestricted && ( typeof( post.access.items ) != 'undefined' ) ) {
for( var j = 0; j < post.access.items.length; j++ ) {
if( post.access.items[j].type = 'public' ) {
public = true;
j = post.access.items.length;
}
}
}
// If a post is public, add it to the list of public posts for userId
if( public ) publicPosts.push( post );
}
}
// If user has more than 100 posts, continue with the analysis of subsequent batches of 100
pageToken = posts.nextPageToken;
} while (pageToken);
} catch( err ) {
// The code above sometimes fails for unexpected reasons. We
// log this error.
Logger.log( 'Failed on ' + userId + ' with error ' + err );
}
return publicPosts;
}
这是一篇扫描文章的输出,其访问类型与“domainRestricted”:True
相关。此帖子在域内共享
{
"description":"Shared privately",
"domainRestricted":true,
"kind":"plus#acl"
}
下面是一个没有domainRestricted
访问权限的扫描帖子的输出示例。这篇文章与一个圈共享,圈中包含域外的用户,基本上是公开的
{
"description":"Shared privately",
"kind":"plus#acl"
}
下面是一个以Public
作为访问权限的扫描帖子的输出示例。这篇文章是公开的
{
"items":[{"type":"public"}],
"description":"Public",
"kind":"plus#acl"
}
我想更改此代码,以扫描任何不包含访问权限“domainRestricted”:True
的帖子
function checkPublicPosts( userId ) {
var publicPosts = Array();
var pageToken;
try {
do {
Logger.log( 'Scanning posts by ' + userId );
// Search for all Google Plus posts by userId
posts = PlusDomains.Activities.list( userId, 'user', {
maxResults: 100,
pageToken: pageToken
});
// If posts are found, check to see if they are public
if( posts.items ) {
for( var i = 0; i < posts.items.length; i++ ) {
var post = posts.items[i];
var public = false;
if( !post.access.domainRestricted && ( typeof( post.access.items ) != 'undefined' ) ) {
for( var j = 0; j < post.access.items.length; j++ ) {
if( post.access.items[j].type = 'public' ) {
public = true;
j = post.access.items.length;
}
}
}
// If a post is public, add it to the list of public posts for userId
if( public ) publicPosts.push( post );
}
}
// If user has more than 100 posts, continue with the analysis of subsequent batches of 100
pageToken = posts.nextPageToken;
} while (pageToken);
} catch( err ) {
// The code above sometimes fails for unexpected reasons. We
// log this error.
Logger.log( 'Failed on ' + userId + ' with error ' + err );
}
return publicPosts;
}
函数checkPublicPosts(userId){
var publicPosts=Array();
var pageToken;
试一试{
做{
Logger.log('Scanning posts by'+userId);
//按用户ID搜索所有Google Plus帖子
posts=PlusDomains.Activities.list(用户ID,'user'{
最大结果:100,
pageToken:pageToken
});
//如果找到帖子,检查它们是否公开
如果(posts.items){
对于(var i=0;i
有人能帮我吗