asp.net - Sharing Moments in GooglePlus from C# -
are there libraries out there c# wrap process of sharing moments user's google+ account (or stream)? i'm looking take clientid , clientsecret, , maybe apikey along user's id send text user has decided share his/her friends.
if not, have example of creating webrequest accomplish same thing, appreciated too!
i've reviewed landing page: https://developers.google.com/+/quickstart/csharp
but i'm trying integrate existing mvc5 application has auth googleplus taken care of.
the correct client using google apis google .net api client library, available via nuget. additional libraries specific apis required if use more core library. plus, need google.apis.plus.v1 package.
after have added projects , have configured api client, writing app activities easy as:
/// <summary>the app activity type add.</summary> private const string add_activity_type = @"http://schemas.google.com/addactivity"; // construct plus service, i'll assume helper here. plusservice plusservice = getplusservice(credentials); moment addmoment = new moment(); itemscope target = new itemscope() { url = contenturl }; addmoment.type = add_activity_type; addmoment.target = target; moment response = null; try { response = plusservice.moments.insert(addmoment, "me", momentsresource.insertrequest.collectionenum.vault).execute(); } catch (system.aggregateexception) { /* occurs when server can't seen google. */ } catch (google.googleapiexception) { /* occurs when server can't seen google. */ } how authenticate user , authorize client access google apis in mvc can found on blog: asp.net mvc openid , oauth.
a final note, app activities require specify app activities pseudo-scope (request_visible_actions) easier sign-in button via framework. if getting 401 errors, culprit.
Comments
Post a Comment