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

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

    Public Sub GenerateReport()
        ' Gets and displays the preferred locale set for the specified client.  
        ' You must have a web reference added to the 
        ' URL "https://sandbox.google.com/api/adsense/v2/AdSenseForContentService?wsdl" and name the 
        ' webreference as "AdSenseAccounts"
        Dim contentService As New AdSenseContent.AdSenseForContentServiceService

        ' Set the headers before you call the service method.

        ' Set the developer account email
        contentService.developer_emailValue = New AdSenseContent.developer_email()
        contentService.developer_emailValue.Text = New String() {"sandboxdeveloper@google.com"}

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

        ' '' Set the client Id. 
        contentService.client_idValue = New AdSenseContent.client_id()
        contentService.client_idValue.Text = New String() {txtClientID.Text}

        Try
            Dim result As AdSenseContent.ChannelService_Data() = contentService.getChannels(txtClientID.Text, ddlChannelType.SelectedValue)

            lblData.Text = "<table cellpadding=6>"
            lblData.Text &= "<TR><TD align=center><B>Id</B></TD><TD align=center><B>Type</B></TD><TD align=center><B>Name</B></TD><TD align=center><B>Status</B></TD></TR>"
            For Each d As AdSenseContent.ChannelService_Data In result
                lblData.Text &= "<TR>"
                lblData.Text &= "<TD>" & d.id & "</TD>"
                lblData.Text &= "<TD>" & d.type & "</TD>"
                lblData.Text &= "<TD>" & d.name & "</TD>"
                lblData.Text &= "<TD>" & d.status & "</TD>"
                lblData.Text &= "</TR>"
            Next
            lblData.Text &= "</TABLE>"
        Catch ex As System.Web.Services.Protocols.SoapException
            lblData.Text = "<font color=red><B>" & ex.Message & "</B></font>"
        End Try
    End Sub
End Class