if (!$keywordEstimateRequest->isNegative) { $keyword = $keywordEstimateRequest->keyword; $keywordEstimate = $keywordEstimates[$i]; // Find the mean of the min and max values. $meanAverageCpc = ($keywordEstimate->min->averageCpc->microAmount + $keywordEstimate->max->averageCpc->microAmount) / 2; $meanAveragePosition = ($keywordEstimate->min->averagePosition + $keywordEstimate->max->averagePosition) / 2; $meanClicks = ($keywordEstimate->min->clicksPerDay + $keywordEstimate->max->clicksPerDay) / 2; $meanTotalCost = ($keywordEstimate->min->totalCost->microAmount + $keywordEstimate->max->totalCost->microAmount) / 2; printf("Results for the keyword with text '%s' and match type '%s':\n", $keyword->text, $keyword->matchType); printf(" Estimated average CPC in micros: %.0f\n", $meanAverageCpc); printf(" Estimated ad position: %.2f \n", $meanAveragePosition); printf(" Estimated daily clicks: %d\n", $meanClicks); printf(" Estimated daily cost in micros: %.0f\n\n", $meanTotalCost); } } } // Don't run the example if the file is being included. if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { return; } try { // Get AdWordsUser from credentials in "../auth.ini" // relative to the AdWordsUser.php file's directory. $user = new AdWordsUser(); // Log every SOAP XML request and response. $user->LogAll(); // Run the example. EstimateKeywordTrafficExample($user); } catch (Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); }
public function testEstimateKeywordTrafficExample() { EstimateKeywordTrafficExample($this->user); }