1

晚安,

我尝试将参数添加为注释,但无济于事。我得到了以下代码,但是现在错误是...

ProtocolException as caught
Error occurred while sending a direct message or getting the response.

有人可以帮助我,因为我几乎认为这是不可能的。

Public Shared Function PostPlus2(sMsg As String) As Boolean
        Try

            Dim sPath_Absolut As String = HttpContext.Current.Server.MapPath("~/funcoes/")

            Dim ServiceAccountId As String = "****************************.apps.googleusercontent.com"
            Dim ServiceAccountUser As String = "***************************@developer.gserviceaccount.com"
            Dim Certificado As String = sPath_Absolut + "Certificado\privatekey.p12"

            Dim oCertificate As X509Certificate2 = New X509Certificate2(Certificado, "notasecret", X509KeyStorageFlags.Exportable) 'Or X509KeyStorageFlags.MachineKeySet

            'Dim GooAuthServer As DotNetOpenAuth.OAuth2.AuthorizationServerDescription = GoogleAuthenticationServer.Description
            'GooAuthServer.AuthorizationEndpoint = New Uri(GooAuthServer.AuthorizationEndpoint.AbsoluteUri + "?" + "request_visible_actions=http://schemas.google.com/AddActivity" + "&" + "access_type=offline")
            'Dim oClient As New AssertionFlowClient(GooAuthServer, oCertificate) With

            Dim oClient As New AssertionFlowClient(GoogleAuthenticationServer.Description, oCertificate) With
            {
            .ServiceAccountId = ServiceAccountUser,
            .ServiceAccountUser = "************@gmail.com",
            .Scope = Plus.v1.PlusService.Scopes.PlusMe.GetStringValue()
                                }


            Dim oAuth As New OAuth2Authenticator(Of AssertionFlowClient)(oClient, AddressOf AssertionFlowClient.GetState)
            Dim oInitializer As New BaseClientService.Initializer() With
            {
            .Authenticator = oAuth
            }

            Dim oPlusServ As New Plus.v1.PlusService(oInitializer)

            Dim body As New Plus.v1.Data.Moment()
            Dim target As New Plus.v1.Data.ItemScope()
            target.Id = "4"
            target.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png"
            target.Type = "http://schemas.google.com/AddActivity"
            target.Description = "teste description"
            target.Name = "teste name"
            target.Url = "https://developers.google.com/+/web/snippet/examples/thing"

            body.Target = target
            body.Type = "http://schemas.google.com/AddActivity"

            Dim insert As New Plus.v1.MomentsResource.InsertRequest(
                    oPlusServ,
                    body,
                    "me",
                    Plus.v1.MomentsResource.Collection.Vault)

            insert.Fetch()
            'Dim wrote As Plus.v1.Data.Moment = insert.Fetch()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function
4

1 回答 1

2

为了能够编写 AppActivity,您需要在配置 Google+ 登录按钮时设置 request-visible-actions 参数。此参数指示您打算编写哪些 AppActivityType。您可以在https://developers.google.com/+/web/app-activities/?hl=en或观看此 Google+ 开发者直播剧集了解更多信息: http ://www.youtube.com/watch?v= cQC_EanIaUw#t=6m46s

于 2013-04-10T00:43:35.427 回答