I'm trying to share text and image on my Google plus stream. This text and image would be set by me.
I have do a lot of Research on this i have founded that Google plus API is read only then what did the moment insert do in G+ API ...??
Is there any way if i can sync the text from my Facebook or twitter account. I have make this application in C#.
My Code to add moment is working fine but did'nt understand that where it is adding the moment
private async Task Run()
{
UserCredential credential;
var initializer = new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = secrets,
Scopes = new[] { PlusService.Scope.PlusLogin }
};
var flow = new AAGoogleAuthorizationCodeFlow(initializer);
credential = await new AuthorizationCodeInstalledApp(flow, new LocalServerCodeReceiver()).AuthorizeAsync
("user", CancellationToken.None).ConfigureAwait(false);
var service = new PlusService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Gus API",
});
Moment body = new Moment();
ItemScope itemScope = new ItemScope();
itemScope.Id = "**********************";
itemScope.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
itemScope.Type = "";
itemScope.Description = "The description for the action";
itemScope.Name = "An example of add activity";
body.Target = itemScope;
body.Type = "http://schema.org/AddAction";
MomentsResource.InsertRequest insert =
new MomentsResource.InsertRequest(
service,
body,
"me",
MomentsResource.InsertRequest.CollectionEnum.Vault);
Moment wrote = insert.Execute();
}
public static ClientSecrets secrets = new ClientSecrets()
{
ClientId = "***********************",
ClientSecret = "***************"
};
public class AAGoogleAuthorizationCodeRequestUrl : GoogleAuthorizationCodeRequestUrl
{
[Google.Apis.Util.RequestParameterAttribute("request_visible_actions", Google.Apis.Util.RequestParameterType.Query)]
public string VisibleActions { get; set; }
public AAGoogleAuthorizationCodeRequestUrl(Uri authorizationServerUrl)
: base(authorizationServerUrl)
{
}
}
public class AAGoogleAuthorizationCodeFlow : AuthorizationCodeFlow
{
public AAGoogleAuthorizationCodeFlow(AuthorizationCodeFlow.Initializer initializer)
: base(initializer)
{
}
public override AuthorizationCodeRequestUrl CreateAuthorizationCodeRequest(string redirectUri)
{
return new AAGoogleAuthorizationCodeRequestUrl(new Uri(AuthorizationServerUrl))
{
ClientId = ClientSecrets.ClientId,
Scope = string.Join(" ", Scopes),
RedirectUri = "http://localhost:4567/",
VisibleActions = "http://schemas.google.com/AddActivity"
};
}
}