Ok, i understand ! thanks for all !

here is the good working code :

 // Get the CampaignTargetService.
                $campaignTargetService = 
$user->GetCampaignTargetService('v200909');

          // Create proximity targets.
                $geoTargetProx = new ProximityTarget();
                $legeopoint= new GeoPoint();
                $legeopoint-
>latitudeInMicroDegrees=floatval($_SESSION['ass_com_lati'])*1000000;
                $legeopoint-
>longitudeInMicroDegrees=floatval($_SESSION['ass_com_longi'])*1000000;
                $geoTargetProx->geoPoint = $legeopoint;
                $geoTargetProx->radiusDistanceUnits = 'KILOMETERS';
                $geoTargetProx->radiusInUnits = $_SESSION['ass_distance2'];

                 // Create addresses.
                $address1 = new Address();
                $address1->streetAddress = 
utf8_encode($_SESSION['ass_com_rue']);
                $address1->cityName = utf8_encode($_SESSION['ass_com_ville']);
                $address1->provinceName = 
utf8_encode($_SESSION['ass_com_region']);
                $address1->postalCode = utf8_encode($_SESSION['ass_com_cp']);
                $address1->countryCode = 'FR';
                $geoTargetProx->address = $address1;
                $geoTargetProx->allowServiceOfAddress = true;


                // Create geo targets.
                $geoTargetList = new GeoTargetList();
                $geoTargetList->campaignId = $campaignId;
                $geoTargetList->targets = array(new CountryTarget('FR'),
$geoTargetProx);


                // Create operations.
                $geoTargetOperation = new CampaignTargetOperation();
                $geoTargetOperation->operand = $geoTargetList;
                $geoTargetOperation->operator = 'SET';



                $operations = array( $geoTargetOperation);

                // Set campaign targets.
                $result = $campaignTargetService->mutate($operations);

Best regards

Tang

On Feb 24, 11:38 pm, AdWords API Advisor
<adwordsapiadvi...@google.com> wrote:
> Hi Tang,
>
> Thank you for posting the complete code, I can see the problem now.
> The operand of a CampaignTargetOperation is a TargetList, not an
> individual target.  In this case the operand should be a
> GeoTargetList:
>
>  http://code.google.com/apis/adwords/v2009/docs/reference/CampaignTarg...
>
> When you set a target list you are overwriting all of the existing
> targets in that list.  So if you are attempting to add a target you
> should
>
> 1) Get the existing GeoTargetList
> 2) Add the new target to it
> 3) Set the GeoTargetList
>
> Best,
> - Eric
>
> On Feb 24, 10:23 am, Tang <guillaumedeneuv...@gmail.com> wrote:
>
> > Thanks for your answer,
>
> > i don't see which field is wrong.
>
> > my code :
>
> > // Create proximity targets.
> >                 $geoTargetProx = new ProximityTarget();
>
> >                 $legeopoint= new GeoPoint();
> >                 $legeopoint->latitudeInMicroDegrees='45746250';
> >                 $legeopoint->longitudeInMicroDegrees='4866748';
>
> >                 $geoTargetProx->geoPoint = $legeopoint;
> >                 $geoTargetProx->radiusDistanceUnits = 'KILOMETERS';
> >                 $geoTargetProx->radiusInUnits = '150';
>
> >                  // Create addresses.
> >                 $address1 = new Address();
> >                 $address1->streetAddress = '4 rue Villon';
> >                 $address1->cityName = 'Lyon';
> >                 $address1->provinceName = 'Rhones';
> >                 $address1->postalCode = '69003';
> >                 $address1->countryCode = 'FR';
>
> >                 $geoTargetProx->address = $address1;
> >                 $geoTargetProx->allowServiceOfAddress = true;
>
> >                 $proxTargetOperation = new CampaignTargetOperation();
> >                 $proxTargetOperation->operand = $geoTargetProx;
> >                 $proxTargetOperation->operator = 'SET';
>
> >                 $operations = array($proxTargetOperation);
>
> >                 // Set campaign targets.
> >                 $result = $campaignTargetService->mutate($operations);
>
> > I really don't see what is wrong.
>
> > I get this error :
>
> > Unmarshalling Error:
> > com.google.ads.api.services.campaignmgmt.campaigntarget.v200909.jaxbgen.Pro 
> > ximityTarget
> > cannot be cast to
> > com.google.ads.api.services.campaignmgmt.campaigntarget.v200909.jaxbgen.Tar 
> > getList
>
> > Can you help me ?
>
> > Thanks a lot !
>
> > On Feb 24, 3:55 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
> > wrote:
>
> > > Hi,
>
> > > The documentation for the ProximityTarget is here:
>
> > >  http://code.google.com/intl/fr/apis/adwords/v2009/docs/reference/Camp...
>
> > > All you need to do is create a new ProximityTarget, set the fields,
> > > and add it to the list of targets in your GeoTargetList.  Are there
> > > specific fields you have questions about?
>
> > > Best,
> > > - Eric Koleda, AdWords API Team
>
> > > On Feb 24, 9:39 am, Tang <guillaumedeneuv...@gmail.com> wrote:
>
> > > > nobody can help me ? Please ...
>
> > > > On Feb 23, 7:24 pm, Guillaume <voisineo...@gmail.com> wrote:
>
> > > > > Hi,
>
> > > > > i actually use the Adwords API in PHP, all is working good except for
> > > > > Geotargeting.
>
> > > > > if i want to target a country i do :
>
> > > > > // Create geo targets.
> > > > > $geoTargetList = new GeoTargetList();
> > > > > $geoTargetList->campaignId = $campaignId;
> > > > > $geoTargetList->targets = array(new CountryTarget('FR'));
>
> > > > > But i don't know how to use ProximityTargets with the api ? I found
> > > > > nothing on the forum :(
>
> > > > > I just would like to target circular geographical regions using exact
> > > > > coordinates.
>
> > > > > I have to use "circle" 
> > > > > (http://code.google.com/intl/fr/apis/adwords/docs/developer/Circle.html
> > > > > ) but i don't know how.
>
> > > > > Can someone help me ?
>
> > > > > Thanks

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

Reply via email to