Re: Fetch Keyword object from Adwords account

2011-11-17 Thread iateadonut


Kevin,

Thanks.

- Moved the adWordsUser instantiation out of the loop.

- This is already done that way:

while ( $row06 = $result06->fetch_object() ) {
$distinctAdGroupId[] = (float) $row06-
>adGroupId;}

Notice that all the adgroupsId's are put into an array and then:

$adGroupIdPredicate = new Predicate('AdGroupId', 'IN',
$distinctAdGroupId);


Thank you so much for reviewing the code.  All the developers working
with your code really appreciate your help and the extent of your
documentation/examples.


On Nov 4, 8:49 am, Kevin Winter  wrote:
> Hi,
>   The PHP example as posted will get the job done, but there are a few
> improvements that could be made to make it more efficient.
>
> - Since all these keywords appear to be in the same account, you can move
> the instantiation of the AdWordsUser outside the while loop.  This is
> especially important if you will be requesting a large number of keywords,
> because with the current code it will request an AuthToken (valid for two
> weeks) for each keyword, which could easily trigger a CAPTCHA challenge.
> - Likewise, you could change the predicate to include ALL AdGroupIds
> instead of one per request.
>
> I'd also like to mention that you can use Predicates when defining reports,
> which may help them return more quickly (especially for a large number of
> Keywords).
>
> - Kevin Winter
> AdWords API Team

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@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


Re: Fetch Keyword object from Adwords account

2011-11-04 Thread Kevin Winter
Hi,
  The PHP example as posted will get the job done, but there are a few 
improvements that could be made to make it more efficient.

- Since all these keywords appear to be in the same account, you can move 
the instantiation of the AdWordsUser outside the while loop.  This is 
especially important if you will be requesting a large number of keywords, 
because with the current code it will request an AuthToken (valid for two 
weeks) for each keyword, which could easily trigger a CAPTCHA challenge.
- Likewise, you could change the predicate to include ALL AdGroupIds 
instead of one per request.

I'd also like to mention that you can use Predicates when defining reports, 
which may help them return more quickly (especially for a large number of 
Keywords).

- Kevin Winter
AdWords API Team

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@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


Re: Fetch Keyword object from Adwords account

2011-11-02 Thread iateadonut
PHP ok?  This is what I have in my notes:


//adWords API stuff - see GetAllAdGroupCriteria.php
//make array containing all adGroupId's
$query06 = "select distinct(adGroupId) from $db.$prefix"."keywords
where ExternalCustomerId='$customerId' and
( month(date)=month(date(now())) or month(date)=month(date(now()-
interval 1 month)) ) group by keywordText";
$result06 = $mysqli->query($query06);
while ( $row06 = $result06->fetch_object() ) {
$distinctAdGroupId[] = (float) $row06->adGroupId;   }
try {
  // Get AdWordsUser from credentials in "../auth.ini"
  // relative to the AdWordsUser.php file's directory.
  $user = new AdWordsUser();
$user->SetClientId($customerId);
  // Log SOAP XML request and response.
  $user->LogDefaults();
  // Get the AdGroupCriterionService.
  $adGroupCriterionService = $user-
>GetAdGroupCriterionService('v201101');
  // Create selector.
  $selector = new Selector();
  $selector->fields = array('Id', 'KeywordText', 'MaxCpc',
'FirstPageCpc');
  //to get all possible fields, see
http://code.google.com/apis/adwords/docs/appendix/selectorfields.html#v201101-AdGroupCriterionService
  $selector->ordering = array(new OrderBy('AdGroupId', 'ASCENDING'));
  // Create predicates.
  $adGroupIdPredicate = new Predicate('AdGroupId', 'IN',
$distinctAdGroupId);
  $selector->predicates = array($adGroupIdPredicate);
  // Get all ad group criteria.
  $page = $adGroupCriterionService->get($selector);
} catch (Exception $e) {
  print $e->getMessage();
}
//*/

I do that first to create an object with all the keyword information I
might need to grab for purposes of my script, then I use a function to
search through that data and return an object with whatever
information I need:

//*
function getLastMonthMaxCPC($keywordId, $page5) {

foreach ($page5 as $ad) {

if ( $ad->Id == $keywordId ) {

$maxCPC2 = new stdClass;
if(isset($ad->avgCPC)) {
$maxCPC2->avgCPC = $ad->avgCPC;
$maxCPC2->convRate = $ad->convRate; }
return $maxCPC2;
}
}
}
//*/



On Nov 1, 6:14 am, Nikhil Gaur  wrote:
> Hi,
>
> In my application I want to fetch keyword report, but it takes too
> much time so I am planning to create a separate operation for some
> special keywords. For these keywords I will not fetch reports but I'll
> fetch their keyword object which contains complete keyword details
> like average cpc, impression etc.
>
> This kind of thing is possible in adCenter API so I am assuming that
> this will also be available in Adwords as well. In adCenter we can
> fetch individual keyword abject and then check theor details.
>
> If any one knows how to fetch keyword object in Adwords please reply.
>
> Thanks

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@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