Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you need to do is either set the target URL or set the other metadata inside of the moment body. If you are setting both, you will get an error. The following code should work:</p> <pre><code>ItemScope target = new ItemScope(); // target.Id = "replacewithuniqueforaddtarget"; // This is optional. target.Url = "https://developers.google.com/+/web/snippet/examples/widget"; Moment body = new Moment(); body.Target = target; body.Type = "http://schemas.google.com/AddActivity"; MomentsResource.InsertRequest insert = new MomentsResource.InsertRequest(service, body, "me", MomentsResource.Collection.Vault); Moment wrote = insert.Execute(); </code></pre> <p>Or the following code:</p> <pre><code>ItemScope target = new ItemScope(); target.Id = "replacewithuniqueforaddtarget"; // Optional target.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png"; target.Type = "http://schemas.google.com/AddActivity"; target.Description = "The description for the activity"; target.Name = "An example of add activity"; Moment body = new Moment(); body.Target = target; body.Type = "http://schemas.google.com/AddActivity"; MomentsResource.InsertRequest insert = new MomentsResource.InsertRequest(service, body, "me", MomentsResource.Collection.Vault); Moment wrote = insert.Execute(); </code></pre> <p>I just tested the above code with the 1.4 library, this should work in either case.</p> <p>It's possible that you are not creating a Google+ service client but instead are just creating the Tasks service client and trying to use that. The following boilerplate is a full example that constructs a Google+ service and writes a moment:</p> <pre><code> // Register the authenticator and construct the Plus service // for performing API calls on behalf of the user. _authState = YOUR_AUTHSTATE_OBJECT; AuthorizationServerDescription description = GoogleAuthenticationServer.Description; var provider = new WebServerClient(description); provider.ClientIdentifier = CLIENT_ID; provider.ClientSecret = CLIENT_SECRET; var authenticator = new OAuth2Authenticator&lt;WebServerClient&gt;( provider, GetAuthorization) { NoCaching = true }; ps = new PlusService(new BaseClientService.Initializer() { Authenticator = authenticator }); Moment body = new Moment(); body.Target = target; body.Type = "http://schemas.google.com/AddActivity"; MomentsResource.InsertRequest insert = new MomentsResource.InsertRequest(ps, body, "me", MomentsResource.Collection.Vault); Moment wrote = insert.Execute(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload