Hi Shwetha,

Thanks for your reply!

I had already made the upgrade to the new libraries a few months ago. 
However, I don't think the problem is my code as I can't even get the 
official examples to run.

I tried to start from scratch. Here's what I did:

   - I got composer and ran the following from command line:
   - *php composer.phar require googleads/googleads-php-lib*
   - 
   - 
*cat 
   
vendor/googleads/googleads-php-lib/examples/AdWords/v201705/BasicOperations/GetCampaigns.php
 
   *

The result is the example from the old library:
<?php
/**
 * This example gets all campaigns in the account. To add a campaign, run
 * AddCampaign.php.
 *
 * Copyright 2016, Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package    GoogleApiAdsAdWords
 * @subpackage v201705
 * @category   WebServices
 * @copyright  2016, Google Inc. All Rights Reserved.
 * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License,
 *             Version 2.0
 */

// Include the initialization file
require_once dirname(dirname(__FILE__)) . '/init.php';

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetCampaignsExample(AdWordsUser $user) {
  // Get the service, which loads the required classes.
  $campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);

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

  // Create paging controls.
  $selector->paging = new Paging(0, 
AdWordsConstants::RECOMMENDED_PAGE_SIZE);

  do {
    // Make the get request.
    $page = $campaignService->get($selector);

    // Display results.
    if (isset($page->entries)) {
      foreach ($page->entries as $campaign) {
        printf("Campaign with name '%s' and ID '%s' was found.\n",
            $campaign->name, $campaign->id);
      }
    } else {
      print "No campaigns were found.\n";
    }

    // Advance the paging index.
    $selector->paging->startIndex += 
AdWordsConstants::RECOMMENDED_PAGE_SIZE;
  } while ($page->totalNumEntries > $selector->paging->startIndex);
}

// 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.
  GetCampaignsExample($user);
} catch (Exception $e) {
  printf("An error has occurred: %s\n", $e->getMessage());
}

This is apparently not the file from the master branch. But shouldn't *php 
composer.phar require googleads/googleads-php-lib *have gotten me 
everything from the master branch?

Thanks & sorry if I'm just missing something...
Martin




Am Mittwoch, 7. Juni 2017 18:57:20 UTC+2 schrieb Shwetha Vastrad (AdWords 
API Team):
>
> Hi, 
>
> A new ads php client library was released 
> <http://googleadsdeveloper.blogspot.com/2016/12/announcing-new-ads-php-client-library.html>
>  in 
> December 2016. In this library you need construct an API session using the 
> AdWordsSessionBuilder.php 
> <https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/AdWords/AdWordsSessionBuilder.php>
>  and 
> obtain a service from the ads services factory, specifying the service 
> class using ::class 
> <http://www.google.com/url?q=http%3A%2F%2Fphp.net%2Fmanual%2Fen%2Flanguage.oop5.basic.php%23language.oop5.basic.class.class&sa=D&sntz=1&usg=AFQjCNH7a5fPnF8g7JJlBNLEGUJbr_Iu-g>
>  after 
> it has been imported. It looks like the example you have in your system 
> belongs to the old library which has been moved to a deprecated branch 
> <https://github.com/googleads/googleads-php-lib/tree/deprecated>. Please 
> try using the GetCampaigns.php 
> <https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201705/BasicOperations/GetCampaigns.php>
>  example 
> from the master branch and let me know if it works. Please see this upgrading 
> guide 
> <https://github.com/googleads/googleads-php-lib/blob/master/UPGRADING.md> for 
> more details. 
>
> Regards,
> Shwetha, AdWords API Team.
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/a7804fd0-28b2-4a48-8b67-ce139c234bdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Re: PHP Client ... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum
    • Re: PHP Cl... Martin Roettgerding
      • Re: PH... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum
        • Re... Martin Roettgerding
        • Re... Martin Roettgerding
          • ... Martin Roettgerding
            • ... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum
              • ... Martin Roettgerding

Reply via email to