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 GetWebsiteUrl
    Inherits System.Web.UI.Page

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

    Public Sub GetWebSiteUrl()
        ' Gets and displays the website associated with the specified client.  
        ' 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() {txtClientID.Text}

        Try
            Dim result As String = accountService.getWebsiteUrl(0)

            Response.Write("<BR>Result: " & result)
        Catch ex As System.Web.Services.Protocols.SoapException
            Response.Write("<font color=red><B>" & ex.Message & "</B></font>")
        End Try
    End Sub
End Class