当前位置: 首页>>代码示例>>PHP>>正文


PHP AdWordsUser::getService方法代码示例

本文整理汇总了PHP中AdWordsUser::getService方法的典型用法代码示例。如果您正苦于以下问题:PHP AdWordsUser::getService方法的具体用法?PHP AdWordsUser::getService怎么用?PHP AdWordsUser::getService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdWordsUser的用法示例。


在下文中一共展示了AdWordsUser::getService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(\AdWordsUser $adwords, LoggerInterface $logger)
 {
     $this->adwords = $adwords;
     $this->logger = $logger;
     $this->loop = $loop = EventLoopFactory::create();
     $handler = new RingAdapter($loop);
     $this->httpClient = new HttpClient(['handler' => $handler]);
     $this->setLabelService($adwords->getService('LabelService'));
 }
开发者ID:bashilbers,项目名称:AdWordsApiScripts,代码行数:9,代码来源:LinkChecker.php

示例2: UpgradeLegacySitelinksExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param array $campaignIds the IDs of the campaign to add the sitelinks to
 */
function UpgradeLegacySitelinksExample(AdWordsUser $user, $campaignIds)
{
    $campaignAdExtensionService = $user->getService('CampaignAdExtensionService', ADWORDS_VERSION);
    $feedService = $user->getService('FeedService', ADWORDS_VERSION);
    $feedItemService = $user->getService('FeedItemService', ADWORDS_VERSION);
    $feedMappingService = $user->getService('FeedMappingService', ADWORDS_VERSION);
    $campaignFeedService = $user->getService('CampaignFeedService', ADWORDS_VERSION);
    // Try to retrieve an existing feed that has been mapped for use with
    // sitelinks. if multiple such feeds exist, the first matching feed is
    // retrieved. You could modify this code example to retrieve all the feeds
    // and pick the appropriate feed based on user input.
    $siteLinksFeed = GetExistingFeed($feedMappingService);
    if (empty($siteLinksFeed)) {
        // Create a feed for storing sitelinks.
        $siteLinksFeed = CreateSiteLinksFeed($feedService);
        // Map the feed for using with sitelinks.
        CreateSiteLinksFeedMapping($feedMappingService, $siteLinksFeed);
    }
    foreach ($campaignIds as $campaignId) {
        // Get legacy sitelinks for the campaign.
        $extension = GetLegacySitelinksForCampaign($campaignAdExtensionService, $campaignId);
        if (!empty($extension)) {
            // Get the sitelinks.
            $legacySiteLinks = $extension->adExtension->sitelinks;
            // Add the sitelinks to the feed.
            $siteLinkFeedItemIds = CreateSiteLinkFeedItems($feedItemService, $siteLinksFeed, $legacySiteLinks);
            // Associate feeditems to the campaign.
            AssociateSitelinkFeedItemsWithCampaign($campaignFeedService, $siteLinksFeed, $siteLinkFeedItemIds, $campaignId);
            // Once the upgraded sitelinks are added to a campaign, the legacy
            // sitelinks will stop serving. You can delete the legacy sitelinks
            // once you have verified that the migration went fine. In case the
            // migration didn't succeed, you can roll back the migration by deleting
            // the CampaignFeed you created in the previous step.
            DeleteLegacySitelinks($campaignAdExtensionService, $extension);
        }
    }
}
开发者ID:phobik,项目名称:google-api-adwords-php,代码行数:42,代码来源:UpgradeLegacySitelinks.php

示例3: testIntegrationOAuth2Handler_InvalidAccessToken

 /**
  * Tests that the access_token is refreshed correctly and set on the URL
  * params for this client library.
  */
 public function testIntegrationOAuth2Handler_InvalidAccessToken()
 {
     $credentialsOverride = array('access_token' => sprintf('TEST_ACCESS_TOKEN_%s', uniqid()), 'refresh_token' => sprintf('TEST_REFRESH_TOKEN_%s', uniqid()), 'expires_in' => '3600', 'timestamp' => strtotime('-1 day'));
     $credentialsRefreshed = array('access_token' => sprintf('TEST_ACCESS_TOKEN_%s', uniqid()), 'refresh_token' => $credentialsOverride['refresh_token'], 'expires_in' => '3600', 'timestamp' => time(), 'Foo' => 'bar');
     // Get the response xml
     $xmlResponse = $this->assetHelper->getAsset(sprintf(self::RESPONSE_NAME, self::SERVICE));
     // Create a regular AdWordsUser
     $user = new AdWordsUser($this->assetHelper->getAssetPath('auth.ini'));
     $campaignService = $user->getService(self::SERVICE);
     $oAuth2Info = $user->GetOAuth2Info();
     $newOAuth2Info = array_merge($oAuth2Info, $credentialsOverride);
     $user->SetOAuth2Info($newOAuth2Info);
     // Get the expected auth param for the URL.
     $oauth2Url = http_build_query(array('access_token' => $credentialsRefreshed['access_token']));
     // Setup the mocked OAuth2Handler class.
     $oAuth2Handler = $this->getMock('SimpleOAuth2Handler', array('RefreshAccessToken'));
     $oAuth2Handler->expects($this->any())->method('RefreshAccessToken')->will($this->returnValue($credentialsRefreshed));
     $user->SetOAuth2Handler($oAuth2Handler);
     // Setup the test.
     $soapClientMock = $this->getMockBuilder('SoapClient')->setMethods(array('__doRequest'))->disableOriginalConstructor()->getMock();
     // Checking for the URL param for the auth token
     // (passed in the second function param)
     $soapClientMock->expects($this->any())->method('__doRequest')->with($this->anything(), $this->stringContains($oauth2Url))->will($this->returnValue($xmlResponse));
     // Set the transport layer on the soap client to be the mocked soap client.
     $campaignService->__SetTransportLayer($soapClientMock);
     // Create selector.
     $selector = new Selector();
     // Specify the fields to retrieve.
     $selector->fields = array('Login', 'CustomerId', 'Name');
     // Make the get request.
     $campaignService->get($selector);
 }
开发者ID:phobik,项目名称:google-api-adwords-php,代码行数:36,代码来源:AdWordsIntegrationTest.php


注:本文中的AdWordsUser::getService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。