code sample for VB.Net

120 views
Skip to first unread message

tomasz

unread,
Jan 28, 2005, 9:57:25 AM1/28/05
to adwor...@googlegroups.com
Can someone post a code sample for VB.Net. I have a hard time with C#,
thanks

Brad

unread,
Jan 28, 2005, 12:33:04 PM1/28/05
to adwor...@googlegroups.com
Heres a quick translation of Googles c# sample #1. No warranty on this
(except that it builds) since I normally use c#. Uses a web reference
named "com.google.adwords" from the generated from the wsdl. Hope this
helps get you started.

Imports ConsoleApplication4.com.google.adwords

Module Module1
Sub Main()
' To generate the proxy class in Windows, use wsdl.exe like
this:
' wsdl.exe
http://adwords.google.com/api/adwords/v2/AdGroupService?wsdl

' Display the name and maximum cost-per-click of an AdGroup
'
' The id of the adgroup to be retrieved
Dim adgroupid As Integer = 34299

' instantiate AdGroup service
Dim service As AdGroupServiceService
service = New AdGroupServiceService

' set headers
Dim myUseragent As String = "YOUR COMPANY -- VB.Net Get AdGroup
Test"
Dim myEmail As String = "your...@yourcompany.com"
Dim myPassword As String = "secret"
Dim myToken As String = "ABcdeFGH93KL-NOPQ_STUv"

service.useragentValue = New useragent
service.useragentValue.Text = New String() {myUseragent}

service.emailValue = New email
service.emailValue.Text = New String() {myEmail}

service.passwordValue = New password
service.passwordValue.Text = New String() {myPassword}

service.tokenValue = New token
service.tokenValue.Text = New String() {myToken}

' Retrieve adgroup data and display the information
Dim adgroup As AdGroup = service.getAdGroup(adgroupid)

Console.WriteLine("The Ad Group name is " & adgroup.name)
Console.WriteLine("The max CPC is " & adgroup.maxCpc)
End Sub

End Module

tomasz

unread,
Jan 28, 2005, 2:51:04 PM1/28/05
to adwor...@googlegroups.com
Unfortunately it deos not work

Brad

unread,
Jan 28, 2005, 3:19:05 PM1/28/05
to adwor...@googlegroups.com
It works for me if I replace the AdID and login info with valid
credentials. The top "Imports" statement is app specific, that is, my
app was named ConsoleApplication4. Good luck.

tomasz

unread,
Jan 28, 2005, 3:41:29 PM1/28/05
to adwor...@googlegroups.com
Where I can get Ad Group number (integer) I look in my control pannel
and I can not find a nubmber?

thank for your help

tomasz

unread,
Jan 28, 2005, 4:03:13 PM1/28/05
to adwor...@googlegroups.com
Thanks Brad, you were correct thanks for help,

da

unread,
Jan 31, 2005, 10:02:51 AM1/31/05
to adwor...@googlegroups.com
Brad
I was assigned a task to create a client and found you VB code here in
the forum.. when I tried to build it I got an error... Type "useragent"
is not defined on the following line of code. Where is or should this
be defined.
service.useragentValue = New useragent

Thanks for any help.

John Krystynak

unread,
Feb 10, 2005, 4:16:29 PM2/10/05
to da, adwor...@googlegroups.com
You need to add a Web Reference to the project. You type in the wsdl
location - i.e.:
https://adwords.google.com/api/adwords/v2/AdGroupService?wsdl

useragent is created automatically by the webreference as a Class:
Public Class useragent
Inherits System.Web.Services.Protocols.SoapHeader
Member of: AdWordsAPI.com.google.adwords


I got this example to work with Visual Studio .NET --- thanks Brad!
--
Check out my AdWords and Overture blog:
http://gotads.blogspot.com
Reply all
Reply to author
Forward
0 new messages