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


PHP AdWordsUser::GetUserAgent方法代码示例

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


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

示例1: testGetClientLibraryUserAgentReturnsCorrectlyFormattedUserAgent

 /**
  * @covers AdsUser::GetClientLibraryUserAgent
  */
 public function testGetClientLibraryUserAgentReturnsCorrectlyFormattedUserAgent()
 {
     $USER_AGENT = 'AdWordsApiPhpClient-test';
     $LIB_NAME = 'AwApi-PHP';
     $COMMON_NAME = 'Common-PHP';
     $VERSION_REGEX = '\\d{1,2}\\.\\d{1,2}\\.\\d{1,2}';
     $user = new AdWordsUser($this->authIniFilePath, 'devToken', $USER_AGENT, null, null, $this->mockOAuth2Credential);
     // Example: "AdWordsApiPhpClient-test (AwApi-PHP/4.1.1, Common-PHP/5.0.0,
     // PHP/5.4.8)"
     $search = sprintf('/^%s \\(%s\\/%s, %s\\/%s, PHP\\/%s\\)$/', preg_quote($user->GetUserAgent()), preg_quote($LIB_NAME), $VERSION_REGEX, preg_quote($COMMON_NAME), $VERSION_REGEX, preg_quote(PHP_VERSION));
     $this->assertRegExp($search, $user->GetClientLibraryUserAgent());
 }
开发者ID:nicholasscottfish,项目名称:googleads-php-lib,代码行数:15,代码来源:AdWordsUserTest.php

示例2: testGetClientLibraryUserAgent

 /**
  * Tests that the user agent header is properly set for this client library.
  *
  * @covers AdsUser::GetClientLibraryUserAgent
  */
 public function testGetClientLibraryUserAgent()
 {
     $USER_AGENT = 'AdWordsApiPhpClient-test';
     $LIB_NAME = 'AwApi-PHP';
     $COMMON_NAME = 'Common-PHP';
     $VERSION_REGEX = '\\d{1,2}\\.\\d{1,2}\\.\\d{1,2}';
     $authIniFilePath = tempnam(sys_get_temp_dir(), 'auth.ini.');
     $settingsIniFilePath = tempnam(sys_get_temp_dir(), 'settings.ini.');
     $user = new AdWordsUser($authIniFilePath, NULL, NULL, NULL, NULL, $USER_AGENT, NULL, $settingsIniFilePath);
     // Example: "testApplication (AwApi-PHP/4.1.1, Common-PHP/5.0.0, PHP/5.4.8)"
     $search = sprintf('/^%s \\(%s\\/%s, %s\\/%s, PHP\\/%s\\)$/', preg_quote($user->GetUserAgent()), preg_quote($LIB_NAME), $VERSION_REGEX, preg_quote($COMMON_NAME), $VERSION_REGEX, preg_quote(PHP_VERSION));
     $this->assertRegExp($search, $user->GetClientLibraryUserAgent());
 }
开发者ID:phobik,项目名称:google-api-adwords-php,代码行数:18,代码来源:AdWordsUserTest.php

示例3: testUpdateClientLibraryUserAgent_isIncludeUtilitiesInUserAgent_false

 /**
  * Tests if the user agent doesn't include any usages of ads utilities when
  * isIncludeUtilitiesInUserAgent is false.
  *
  * @covers AdsUser::setIncludeUtilitiesInUserAgent
  * @covers AdsUser::updateClientLibraryUserAgent
  * @covers AdWordsUser::__construct
  */
 public function testUpdateClientLibraryUserAgent_isIncludeUtilitiesInUserAgent_false()
 {
     $USER_AGENT = 'AdWordsApiPhpClient-test';
     $LIB_NAME = 'AwApi-PHP';
     $COMMON_NAME = 'Common-PHP';
     $VERSION_REGEX = '\\d{1,2}\\.\\d{1,2}\\.\\d{1,2}';
     $user = new AdWordsUser($this->authIniFilePath, 'devToken', $USER_AGENT, null, null, $this->mockOAuth2Credential);
     $user->setIncludeUtilitiesInUserAgent('false');
     AdsUtilityRegistry::getInstance()->addUtility('BatchJobHelper');
     $user->updateClientLibraryUserAgent($user->GetUserAgent());
     // Example: "AdWordsApiPhpClient-test (AwApi-PHP/9.0.0, Common-PHP/9.0.0,
     // PHP/5.4.8)"
     $expectedUserAgents = sprintf('/^%s \\(%s\\/%s, %s\\/%s, PHP\\/%s\\)$/', preg_quote($user->GetUserAgent()), preg_quote($LIB_NAME), $VERSION_REGEX, preg_quote($COMMON_NAME), $VERSION_REGEX, preg_quote(PHP_VERSION));
     $this->assertRegExp($expectedUserAgents, $user->GetClientLibraryUserAgent());
 }
开发者ID:googleads,项目名称:googleads-php-lib,代码行数:23,代码来源:AdWordsUserTest.php


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