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