Thanks for recommendation. I'll try it.

On Dec 30, 2:46 am, Evgeniy Bogdanov <[email protected]> wrote:
> You can change your code for cache Location Ids in the database for
> already known IDs...
> This will be faster and cheaper.
>
> Regards,
> Evgeniy.
>
> On 30 дек, 02:00, Minh Le <[email protected]> wrote:
>
>
>
>
>
>
>
> > Thanks for your reply.
>
> > I'm using .NET & C#. I've got the solution from the similar example in
> > the API package. However, it's so painful when I have to look up for
> > over 100 location ids for each campaign!
>
> > public static void Main(string[] args)
> > {
> >       Location loc = new Location();
> >       string state = reader["state"] != null ?
> > stateAbbreviationExpand(reader["state"].ToString()) : "";
> >       string[] cities = new string[] {reader["city"] != null ?
> > reader["city"].ToString() : ""};
> >       loc.id = getLocation(new AdWordsUser(), state, cities);
>
> >       .....
>
> > }
>
> > private static long getLocation(AdWordsUser user, string stateName,
> > string[] locationNames)
> >         {
> >             // Get the LocationCriterionService.
> >             LocationCriterionService locationCriterionService =
> > (LocationCriterionService)user.GetService(AdWordsService.v201109.LocationCr 
> > iterionService);
>
> >             Selector selector = new Selector();
> >             selector.fields = new string[] { "Id", "LocationName",
> > "DisplayType", "ParentLocations" };
>
> >             // Location names must match exactly, only EQUALS and IN
> > are supported.
> >             Predicate predicate1 = new Predicate();
> >             predicate1.field = "LocationName";
> >             predicate1.@operator = PredicateOperator.EQUALS;
> >             predicate1.values = locationNames;
>
> >             // Set the locale of the returned location names.
> >             Predicate predicate2 = new Predicate();
> >             predicate2.field = "Locale";
> >             predicate2.@operator = PredicateOperator.EQUALS;
> >             predicate2.values = new string[] { "en" };
>
> >             selector.predicates = new Predicate[] { predicate1,
> > predicate2 };
>
> >             try
> >             {
> >                 // Make the get request.
> >                 LocationCriterion[] locationCriteria =
> > locationCriterionService.get(selector);
>
> >                 // Display the resulting location criteria.
> >                 foreach (LocationCriterion locationCriterion in
> > locationCriteria)
> >                 {
> >                     if (locationCriterion.location != null &&
> > locationCriterion.location.parentLocations != null)
> >                     {
> >                         foreach (Location location in
> > locationCriterion.location.parentLocations)
> >                         {
> >                             if
> > (location.locationName.Equals(stateName))
> >                             {
> >                                 return locationCriterion.location.id;
> >                             }
> >                         }
> >                     }
> >                 }
> >             }
> >             catch (Exception ex)
> >             {
> >                 Console.WriteLine("Failed to get location criteria.
> > Exception says \"{0}\"", ex.Message);
> >             }
>
> >             return 0;
> >         }
>
> > On Dec 29, 12:59 pm, Evgeniy Bogdanov <[email protected]> wrote:
>
> > > Hi Minh.
>
> > > For PHP you can take a look on example in official 
> > > library:http://code.google.com/p/google-api-adwords-php/source/browse/trunk/e...
>
> > > Regards,
> > > Evgeniy.

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to