SL8t7
SL8t7

Reputation: 647

Google Appscript - Post info from a sheet to a Google Community?

Is there a way to write an appscript (inside the sheet) that posts info (in this case, statistics) to a Google Community? I have found an API script for something similar:

function createPost() {
  var userId = 'me';
  var post = {
    object: {
      originalContent : 'Happy Monday! #caseofthemondays'
    },
    access: {
      items: [{
        type: 'domain'
      }],
      domainRestricted: true
    }
  };

  post = PlusDomains.Activities.insert(post, userId);
  Logger.log('Post created with URL: %s', post.url);
}

But how would I go about pointing that to a specific google community?

Upvotes: 2

Views: 234

Answers (1)

Teyam
Teyam

Reputation: 8112

As mentioned at topmost of your given link, the Google+ Domains service allows you to use the Google+ Domains API in Apps Script.

With the use of Google+ Domains API, you can set restrictions to your posts or give access control to one or more of the following audiences:

  • Domain
  • Extended Circles
  • My Circles
  • Circle
  • Person

When sharing an activity, a user can specify the desired audience such as an individual person or one of their circles. When calling the Google+ Domains API, this audience is specified using the access property. For example, the following activity is being shared with a circle:

{
  /* ... */
  "access": {
    "items": [
      {
        "type": "circle", "id": "5678"
      }
    ],
    "domainRestricted": true
  }
}

To successfully implement this, you should also add members of that particular circle by using Circles: addPeople. With proper authorization and scopes, you can send a request using the following sample format:

PUT https://www.googleapis.com/plusDomains/v1/circles/circleId/people

Please try going through the given documentations for more information and other options like sharing to multiple audiences.

Hope that helps!

Upvotes: 1

Related Questions