AdSense API Samples
Home     Google API Samples     Download Source Code     API Reference     AdSense API Forum     AdSense API Blog    
Account Services Content Services Report Services
Partial Class AddService
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        AssociateAccount()
    End Sub

    Public Sub AssociateAccount()
        ' Add a new publisher account to the existing developer account. You must have a web reference added to 
        ' the URL "https://sandbox.google.com/api/adsense/v2/AccountService?wsdl" and name the 
        ' webreference as "AdSenseAccounts"
        Dim accountService As New AdSenseAccounts.AccountServiceService()

        ' Set the headers before you call the service method.

        ' Set the developer account email
        accountService.developer_emailValue = New AdSenseAccounts.developer_email()
        accountService.developer_emailValue.Text = New String() {"developer7@google.com"}

        ' Set the develoepr account password
        accountService.developer_passwordValue = New AdSenseAccounts.developer_password()
        accountService.developer_passwordValue.Text = New String() {"devpass"}

        ' Set the client Id. 
        accountService.client_idValue = New AdSenseAccounts.client_id()
        accountService.client_idValue.Text = New String() {"none"}

        Dim loginEmail As String = txtEmail.Text
        Dim postalCode As String = txtPostalCode.Text
        Dim phone As String = txtPhone.Text

        Try
            Dim result As AdSenseAccounts.SyndicationService_Data()
            result = accountService.associateExistingAccount(loginEmail, postalCode, phone)

            For Each d As AdSenseAccounts.SyndicationService_Data In result
                Response.Write("<BR>AdSense client id: " & d.id)
                Response.Write("<BR>AdSense type: " & d.type)
            Next
        Catch ex As System.Web.Services.Protocols.SoapException
            Response.Write("<font color=red><B>" & ex.Message & "</B></font>")
        End Try
    End Sub
End Class