本文整理汇总了PHP中MapUtils::GetMap方法的典型用法代码示例。如果您正苦于以下问题:PHP MapUtils::GetMap方法的具体用法?PHP MapUtils::GetMap怎么用?PHP MapUtils::GetMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapUtils
的用法示例。
在下文中一共展示了MapUtils::GetMap方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetAllImagesAndVideosExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetAllImagesAndVideosExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$mediaService = $user->GetService('MediaService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('MediaId', 'Width', 'Height', 'MimeType', 'Name');
$selector->ordering = array(new OrderBy('MediaId', 'ASCENDING'));
// Create predicates.
$selector->predicates[] = new Predicate('Type', 'IN', array('IMAGE', 'VIDEO'));
// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $mediaService->get($selector);
// Display images.
if (isset($page->entries)) {
foreach ($page->entries as $media) {
if ($media->MediaType == 'Image') {
$dimensions = MapUtils::GetMap($media->dimensions);
printf("Image with dimensions '%dx%d', MIME type '%s', and id '%s' " . "was found.\n", $dimensions['FULL']->width, $dimensions['FULL']->height, $media->mimeType, $media->mediaId);
} else {
if ($media->MediaType == 'Video') {
printf("Video with name '%s' and id '%s' was found.\n", $media->name, $media->mediaId);
}
}
}
} else {
print "No images or videos were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
示例2: GetKeywordIdeasExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetKeywordIdeasExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetService('TargetingIdeaService', ADWORDS_VERSION);
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES');
// Create seed keyword.
$keyword = 'mars cruise';
// Create related to query search parameter.
$relatedToQuerySearchParameter = new RelatedToQuerySearchParameter();
$relatedToQuerySearchParameter->queries = array($keyword);
$selector->searchParameters[] = $relatedToQuerySearchParameter;
// Create language search parameter (optional).
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
// Note: As of v201302, only a single language parameter is allowed.
$languageParameter = new LanguageSearchParameter();
$english = new Language();
$english->id = 1000;
$languageParameter->languages = array($english);
$selector->searchParameters[] = $languageParameter;
// Create network search parameter (optional).
$networkSetting = new NetworkSetting();
$networkSetting->targetGoogleSearch = true;
$networkSetting->targetSearchNetwork = false;
$networkSetting->targetContentNetwork = false;
$networkSetting->targetPartnerSearchNetwork = false;
$networkSearchParameter = new NetworkSearchParameter();
$networkSearchParameter->networkSetting = $networkSetting;
$selector->searchParameters[] = $networkSearchParameter;
// Set selector paging (required by this service).
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = MapUtils::GetMap($targetingIdea->data);
$keyword = $data['KEYWORD_TEXT']->value;
$search_volume = isset($data['SEARCH_VOLUME']->value) ? $data['SEARCH_VOLUME']->value : 0;
if ($data['CATEGORY_PRODUCTS_AND_SERVICES']->value === null) {
$categoryIds = '';
} else {
$categoryIds = implode(', ', $data['CATEGORY_PRODUCTS_AND_SERVICES']->value);
}
printf("Keyword idea with text '%s', category IDs (%s) and average " . "monthly search volume '%s' was found.\n", $keyword, $categoryIds, $search_volume);
}
} else {
print "No keywords ideas were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
示例3: UploadImageExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function UploadImageExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$mediaService = $user->GetService('MediaService', ADWORDS_VERSION);
// Create image.
$image = new Image();
$image->data = MediaUtils::GetBase64Data('http://goo.gl/HJM3L');
$image->type = 'IMAGE';
// Make the upload request.
$result = $mediaService->upload(array($image));
// Display result.
$image = $result[0];
$dimensions = MapUtils::GetMap($image->dimensions);
printf("Image with dimensions '%dx%d', MIME type '%s', and id '%s' was " . "uploaded.\n", $dimensions['FULL']->width, $dimensions['FULL']->height, $image->mimeType, $image->mediaId);
}
示例4: UploadMediaBundleExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function UploadMediaBundleExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$mediaService = $user->GetService('MediaService', ADWORDS_VERSION);
// Create HTML5 media.
$html5Zip = new MediaBundle();
$html5Zip->data = MediaUtils::GetBase64Data('https://goo.gl/9Y7qI2');
$html5Zip->type = 'MEDIA_BUNDLE';
// Make the upload request.
$result = $mediaService->upload(array($html5Zip));
// Display result.
$mediaBundle = $result[0];
$dimensions = MapUtils::GetMap($mediaBundle->dimensions);
printf("HTML5 media with ID %d, dimensions '%dx%d', MIME type '%s' was " . "uploaded.\n", $mediaBundle->mediaId, $dimensions['FULL']->width, $dimensions['FULL']->height, $mediaBundle->mimeType);
}
示例5: GetKeywordIdeas
function GetKeywordIdeas($adVersion, \AdWordsUser $user, $keywords)
{
$result = [];
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetService('TargetingIdeaService', $adVersion);
// Create selector.
$selector = new \TargetingIdeaSelector();
$selector->requestType = 'STATS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES');
$locationParameter = new \LocationSearchParameter();
$unitedStates = new \Location();
$unitedStates->id = 2840;
$locationParameter->locations = [$unitedStates];
$networkParameter = new \NetworkSearchParameter();
$networdSettings = new \NetworkSetting();
$networdSettings->targetGoogleSearch = true;
$networdSettings->targetSearchNetwork = false;
$networdSettings->targetContentNetwork = false;
$networdSettings->targetPartnerSearchNetwork = false;
$networkParameter->networkSetting = $networdSettings;
// Create related to query search parameter.
$relatedToQuerySearchParameter = new \RelatedToQuerySearchParameter();
$relatedToQuerySearchParameter->queries = $keywords;
$selector->searchParameters[] = $relatedToQuerySearchParameter;
$selector->searchParameters[] = $locationParameter;
$selector->searchParameters[] = $networkParameter;
// Set selector paging (required by this service).
$selector->paging = new \Paging(0, \AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = \MapUtils::GetMap($targetingIdea->data);
$saerchValue = isset($data['SEARCH_VOLUME']->value) ? $data['SEARCH_VOLUME']->value : 0;
$result[] = ['keyword' => $data['KEYWORD_TEXT']->value, 'value' => $saerchValue];
}
} else {
print "No keywords ideas were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += \AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
return $result;
}
示例6: GetKeywordIdeasExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetKeywordIdeasExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetService('TargetingIdeaService', 'v201109_1');
// Create seed keyword.
$keyword = new Keyword();
$keyword->text = 'mars cruise';
$keyword->matchType = 'BROAD';
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('CRITERION', 'AVERAGE_TARGETED_MONTHLY_SEARCHES', 'CATEGORY_PRODUCTS_AND_SERVICES');
// Create related to keyword search parameter.
$selector->searchParameters[] = new RelatedToKeywordSearchParameter(array($keyword));
// Create keyword match type search parameter to ensure unique results.
$selector->searchParameters[] = new KeywordMatchTypeSearchParameter(array('BROAD'));
// Set selector paging (required by this service).
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = MapUtils::GetMap($targetingIdea->data);
$keyword = $data['CRITERION']->value;
$averageMonthlySearches = isset($data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value) ? $data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value : 0;
$categoryIds = implode(', ', $data['CATEGORY_PRODUCTS_AND_SERVICES']->value);
printf("Keyword idea with text '%s', match type '%s', category IDs " . "(%s) and average monthly search volume '%s' was found.\n", $keyword->text, $keyword->matchType, $categoryIds, $averageMonthlySearches);
}
} else {
print "No keywords ideas were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
示例7: GetPlacementIdeasExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetPlacementIdeasExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetService('TargetingIdeaService', ADWORDS_VERSION);
// Create seed url.
$url = 'mars.google.com';
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'PLACEMENT';
$selector->requestedAttributeTypes = array('CRITERION', 'PLACEMENT_TYPE');
// Create related to url search parameter.
$relatedToUrlSearchParameter = new RelatedToUrlSearchParameter();
$relatedToUrlSearchParameter->urls = array($url);
$relatedToUrlSearchParameter->includeSubUrls = FALSE;
$selector->searchParameters[] = $relatedToUrlSearchParameter;
// Set selector paging (required by this service).
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display related placements.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = MapUtils::GetMap($targetingIdea->data);
$placement = $data['CRITERION']->value;
$placementType = $data['PLACEMENT_TYPE']->value;
printf("Placement with url '%s' and type '%s' was found.\n", $placement->url, $placementType);
}
} else {
print "No related placements were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
示例8: GetKeywordIdeasExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetKeywordIdeasExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetService('TargetingIdeaService', ADWORDS_VERSION);
// Create seed keyword.
$keyword = 'mars cruise';
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES');
// Create related to query search parameter.
$relatedToQuerySearchParameter = new RelatedToQuerySearchParameter();
$relatedToQuerySearchParameter->queries = array($keyword);
$selector->searchParameters[] = $relatedToQuerySearchParameter;
// Set selector paging (required by this service).
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = MapUtils::GetMap($targetingIdea->data);
$keyword = $data['KEYWORD_TEXT']->value;
$search_volume = isset($data['SEARCH_VOLUME']->value) ? $data['SEARCH_VOLUME']->value : 0;
$categoryIds = implode(', ', $data['CATEGORY_PRODUCTS_AND_SERVICES']->value);
printf("Keyword idea with text '%s', category IDs (%s) and average " . "monthly search volume '%s' was found.\n", $keyword, $categoryIds, $search_volume);
}
} else {
print "No keywords ideas were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
示例9: testGetMap
/**
* Test getting a map from an array of map entries.
* @param array $mapEntries an array of map entries
* @param array $map the expected map
* @covers MapUtils::GetMap
* @dataProvider MapEntriesProvider
*/
public function testGetMap(array $mapEntries, array $map)
{
$result = MapUtils::GetMap($mapEntries);
$this->assertEquals($map, $result);
}
示例10: getIdeasByKeywords
/**
* @param string $adVersion
* @param \AdWordsUser $user
* @param array $keywords
* @return array
*/
public static function getIdeasByKeywords($adVersion, \AdWordsUser $user, $keywords)
{
$result = [];
// Get the service, which loads the required classes.
$targetingIdeaService = $user->GetService('TargetingIdeaService', $adVersion);
$selector = self::getIdeasSelector();
// Create related to query search parameter.
$relatedToQuerySearchParameter = new \RelatedToQuerySearchParameter();
$relatedToQuerySearchParameter->queries = $keywords;
$selector->searchParameters[] = $relatedToQuerySearchParameter;
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = \MapUtils::GetMap($targetingIdea->data);
$result[] = ['keyword' => $data[self::ATTRIBUTE_KEYWORD_TEXT]->value];
}
} else {
print "No keywords ideas were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += \AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
return $result;
}
示例11: loadMedia
/**
* @return array|Media\Media[]
*/
public function loadMedia()
{
$this->init();
/* @var $mediaService \MediaService */
$mediaService = $this->user->GetService('MediaService', self::ADWORDS_VERSION);
// Create selector.
$selector = new \Selector(['MediaId', 'Width', 'Height', 'MimeType', 'Name', 'Urls', 'SourceUrl']);
$selector->ordering = array(new \OrderBy('Type', 'ASCENDING'));
// Create predicates.
$selector->predicates[] = new \Predicate('Type', 'IN', array('IMAGE', 'VIDEO'));
// Create paging controls.
$selector->paging = new \Paging(0, \AdWordsConstants::RECOMMENDED_PAGE_SIZE);
$media = [];
do {
// Make the get request.
$page = $mediaService->get($selector);
// Display images.
if (isset($page->entries)) {
foreach ($page->entries as $mediaEntry) {
$urls = $mediaEntry->urls ? \MapUtils::GetMap($mediaEntry->urls) : [];
if ($mediaEntry->MediaType == 'Image') {
$dimensions = \MapUtils::GetMap($mediaEntry->dimensions);
$media[] = new Media\Image($mediaEntry->mediaId, $mediaEntry->name, $urls, $mediaEntry->sourceUrl, $mediaEntry->mimeType, $dimensions);
} else {
if ($mediaEntry->MediaType == 'Video') {
$media[] = new Media\Video($mediaEntry->mediaId, $mediaEntry->name, $urls, $mediaEntry->sourceUrl);
}
}
}
} else {
break;
}
// Advance the paging index.
$selector->paging->startIndex += \AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
return $media;
}