vb.net - How to add moments in google plus using asp.net on server side -
public function googlepluspostnow(byval _postcontent string, byval _postname string, byval _startdate string, byval _linkedbackurl string) boolean dim clientid string = "clientid.apps.googleusercontent.com" dim body new moment dim target new itemscope target.id = "1" target.image = "image" target.type = "http://schemas.google.com/addactivity" target.description = _postcontent target.url = _linkedbackurl target.name = _postname body.target = target body.type = "http://schemas.google.com/addactivity" dim insert new momentsresource.insertrequest(plusservice(), body, clientid, momentsresource.collection.vault) dim wrote moment = insert.fetch() end function private function buildauth() baseclientservice.initializer dim service_account_email string = "yourserviceaccount@developer.gserviceaccount.com" dim service_account_pkcs12_file_path string = "certificate path" dim certificate x509certificate2 = new x509certificate2(service_account_pkcs12_file_path, "notasecret", x509keystorageflags.exportable) dim googleauthserver dotnetopenauth.oauth2.authorizationserverdescription = googleauthenticationserver.description googleauthserver.authorizationendpoint = new uri(googleauthserver.authorizationendpoint.absoluteuri + "?" + "data-requestvisibleactions=addactivity" + "&" + "access_type=offline") dim provider new authentication.oauth2.dotnetopenauth.assertionflowclient(googleauthserver, certificate) {.serviceaccountid = service_account_email, .scope = plus.v1.plusservice.scopes.pluslogin.getstringvalue()} dim auth new oauth2authenticator(of authentication.oauth2.dotnetopenauth.assertionflowclient)(provider, addressof authentication.oauth2.dotnetopenauth.assertionflowclient.getstate) dim init new google.apis.services.baseclientservice.initializer init.apikey = "api key" init.authenticator = auth return init end function private function plusservice() plusservice dim ps new plusservice(buildauth) return ps end function
Comments
Post a Comment