How to include google adword api library in my website

243 views
Skip to first unread message

sho...@multipliersolutions.in

unread,
Dec 30, 2014, 6:02:36 AM12/30/14
to adwor...@googlegroups.com
I am trying to integrate google adwords api in my website ,but it's display some errors 

code is :

error_reporting(-1);
ini_set('display_errors',1);
$path = dirname(__FILE__) . '/../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'adwordsAPI/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';

try {
 // Get AdWordsUser from credentials in "../auth.ini"
 // relative to the AdWordsUser.php file's directory.
 $user = new AdWordsUser();

 // Log SOAP XML request and response.
 $user->LogDefaults();

 // Get the AdGroupAdService.
 $adGroupAdService = $user->GetAdGroupAdService();

 $adGroupId = (float) '01';

 // Create selector.
 $selector = new Selector();
 $selector->fields = array('Id', 'AdGroupId', 'Status');
 $selector->ordering = array(new OrderBy('Id', 'ASCENDING'));

 // Create predicates.
 $adGroupIdPredicate = new Predicate('AdGroupId', 'IN', array($adGroupId));
 // By default disabled ads aren't returned by the selector. To return them
 // include the DISABLED status in a predicate.
 $statusPredicate =
 new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED'));
 $selector->predicates = array($adGroupIdPredicate, $statusPredicate);

 // Get all ads.
 $page = $adGroupAdService->get($selector);

 // Display ads.
 if (isset($page->entries)) {
foreach ($page->entries as $adGroupAd) {
 printf("Ad with id '%s', type '%s', and status '%s' was found.\n",
 $adGroupAd->ad->id, $adGroupAd->ad->AdType, $adGroupAd->status);
}
 } else {
print "No ads were found.\n";
 }
} catch (Exception $e) {
echo 'Inside catch exception';
 print $e->getMessage();
}

And Error is :


Warning: require_once(Google/Api/Ads/Common/Util/Logger.php): failed to open stream: No such file or directory in /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/adwordsAPI/src/Google/Api/Ads/Common/Lib/AdsUser.php on line 31 Fatal error: require_once(): Failed opening required 'Google/Api/Ads/Common/Util/Logger.php' (include_path='.::/var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/../../src') in /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/adwordsAPI/src/Google/Api/Ads/Common/Lib/AdsUser.php on line 31

Josh Radcliff (AdWords API Team)

unread,
Dec 30, 2014, 10:45:55 AM12/30/14
to adwor...@googlegroups.com
Hi,

Before you try to render results in a page, have you been able to successfully run any of the PHP library examples from the command line? Also, I'd check under your include_path for the file mentioned in the error (Logger.php). If you downloaded the library from github, that file should be in the directory specified. If not, please try downloading the library again and make sure you include all directories in the library.

Thanks,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages