update and remove sitelink asset ads php

2023-01-31 Thread Turkmeks DEV
when ı updated site links  give me error like this

Request Id : a96meqnkqlLnHykRjHVvbw mutate_error Error Code  Resource was 
not found.
 how can ı update sitelink asset and remove site links

my code :

  // Creates an extension feed item using the specified feed item 
ID and sitelink text.
$extensionFeedItem = new ExtensionFeedItem([
'resource_name' => 
ResourceNames::forExtensionFeedItem($customerId, $feedItemId),
'sitelink_feed_item' => new SitelinkFeedItem(['link_text' => 
$sitelinkText])
]);

// Constructs an operation that will update the extension feed 
item, using the FieldMasks
// utility to derive the update mask. This mask tells the Google 
Ads API which attributes of
// the extension feed item you want to change.
$extensionFeedItemOperation = new ExtensionFeedItemOperation();
$extensionFeedItemOperation->setUpdate($extensionFeedItem);

$extensionFeedItemOperation->setUpdateMask(FieldMasks::allSetFieldsOf($extensionFeedItem));

// Issues a mutate request to update the extension feed item.
$extensionFeedItemServiceClient = 
$googleAdsClient->getExtensionFeedItemServiceClient();
$response = 
$extensionFeedItemServiceClient->mutateExtensionFeedItems(
$customerId,
[$extensionFeedItemOperation]
);

// Prints the resource name of the updated extension feed item.
/** @var ExtensionFeedItem $updatedExtensionFeedItem */
$updatedExtensionFeedItem = $response->getResults()[0];
printf(
"Updated extension feed item with resource name: '%s'.%s",
$updatedExtensionFeedItem->getResourceName(),
PHP_EOL
);

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/20258169-2b1c-4a8c-9bbc-00ea5178c551n%40googlegroups.com.


get campaign give me error

2022-12-22 Thread Turkmeks DEV
hello ı have like this error but not give me error please answer to me how 
can ı fixed code my code bellow like this
  $oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId("")
->withClientSecret("")
->withRefreshToken(env('GOOGLE_REFRESH_TOKEN'))
->build();
$googleAdsClient = (new GoogleAdsClientBuilder())
->withDeveloperToken("x")
->withOAuth2Credential($oAuth2Credential)
->build();
$customerId="xxx"; 

$googleAdsServiceClient = 
$googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves all campaigns.
$query = 'SELECT campaign.id, campaign.name FROM campaign ORDER 
BY campaign.id';
// Issues a search stream request.
/** @var GoogleAdsServerStreamDecorator $stream */
$stream =
$googleAdsServiceClient->searchStream($customerId, $query);

// Iterates over all rows in all messages and prints the 
requested field values for
// the campaign in each row.
foreach ($stream->iterateAllElements() as $googleAdsRow) {
/** @var GoogleAdsRow $googleAdsRow */
printf(
"Campaign with ID %d and name '%s' was found.%s",
$googleAdsRow->getCampaign()->getId(),
$googleAdsRow->getCampaign()->getName(),
PHP_EOL
);
}


// response result
{
   "message":"The caller does not have permission",
   "code":7,
   "status":"PERMISSION_DENIED",
   "details":[
  {
 "@type":"google.ads.googleads.v12.errors.googleadsfailure-bin",
 "data":""
  },
  {
 "@type":"grpc-status-details-bin",
 "data":""
  },
  {
 "@type":"request-id",
 "data":"dG4bsyfPB5wKMS4_CAkUJQ"
  }
   ]
}

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/1e8911ce-1dc6-4aba-8d9f-3fd94744a755n%40googlegroups.com.


REST interface Grouped operations

2022-12-21 Thread Turkmeks DEV
hello when ı used grouped opertions give me error like this how can ı 
solved this problem

"errorCode": {
"adGroupAdError": "CANNOT_CREATE_DEPRECATED_ADS"
},
"message": "An ad of this type is deprecated and cannot be created. Only 
deletions are permitted.",
"requestId": "fYG6PtjX27Gcyk-N3rqVYg"

 my code below like this

{
'mutateOperations': [
  {
'campaignBudgetOperation': {
  'create': {
'resourceName': 
'customers/${CUSTOMER_ID}/campaignBudgets/-1',
'name': 'My Campaign Budget #${RANDOM}',
'deliveryMethod': 'STANDARD',
'amountMicros': 50,
'explicitlyShared': false
  }
}
  },
  {
'campaignOperation': {
  'create': {
'resourceName': 'customers/${CUSTOMER_ID}/campaigns/-2',
'status': 'PAUSED',
'advertisingChannelType': 'SEARCH',
'geoTargetTypeSetting': {
  'positiveGeoTargetType': 'PRESENCE_OR_INTEREST',
  'negativeGeoTargetType': 'PRESENCE_OR_INTEREST'
},
'name': 'My Search campaign #${RANDOM}',
'campaignBudget': 
'customers/${CUSTOMER_ID}/campaignBudgets/-1',
'targetSpend': {}
  }
}
  },
  {
'adGroupOperation': {
  'create': {
'resourceName': 'customers/${CUSTOMER_ID}/adGroups/-3',
'campaign': 'customers/${CUSTOMER_ID}/campaigns/-2',
'name': 'My ad group #${RANDOM}',
'status': 'PAUSED',
'type': 'SEARCH_STANDARD'
  }
}
  },
  {
'adGroupAdOperation': {
  'create': {
'adGroup': 'customers/${CUSTOMER_ID}/adGroups/-3',
'status': 'PAUSED',
'ad': {
  'expandedTextAd': {
'headlinePart1': 'An example headline1',
'headlinePart2': 'An example headline2',
'description': 'An example description'
  },
  'finalUrls': ['https://www.example.com']
}
  }
}
  }
]
}

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/4b94a4c3-1e5d-4786-a7b3-115cb6a05a09n%40googlegroups.com.


CampaignBudget and CampaignBudgetOperation

2022-12-20 Thread Turkmeks DEV
hi this errror how can ı solve this problem could you help  me

request-id :1qoY53Ce4Sts9Mh_jOjFPQ

"message": "Request contains an invalid argument.", "code": 3, "status": 
"INVALID_ARGUMENT", "details": [ { "@type": 
"google.ads.googleads.v12.errors.googleadsfailure-bin", "data": "" }, { "@type": "grpc-status-details-bin", "data": "" }, { "@type": "request-id", "data": "1qoY53Ce4Sts9Mh_jOjFPQ" 
} ] }

my code like this :

 private static function addCampaignBudget(GoogleAdsClient 
$googleAdsClient, int $customerId)
{
// Creates a campaign budget.
$budget = new CampaignBudget([
'name' => 'Interplanetary Cruise Budget #' . 
getPrintableDatetime(),
'delivery_method' => BudgetDeliveryMethod::STANDARD,
'amount_micros' => 50
]);

// Creates a campaign budget operation.
$campaignBudgetOperation = new CampaignBudgetOperation();
$campaignBudgetOperation->setCreate($budget);

// Issues a mutate request.
$campaignBudgetServiceClient = 
$googleAdsClient->getCampaignBudgetServiceClient();

$response = $campaignBudgetServiceClient->mutateCampaignBudgets(
$customerId,
[$campaignBudgetOperation]
);
   
/** @var CampaignBudget $addedBudget */
$addedBudget = $response->getResults()[0];
 
printf("Added budget named '%s'%s", 
$addedBudget->getResourceName(), PHP_EOL);

return $addedBudget->getResourceName();
}
public function create()
{



$manager_id=xx;  
$customer_id=;  
$random=rand(1,9);
// Replace with your client ID, client secret, and refresh token.
$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId(env('GOOGLE_CLIENT_ID'))
->withClientSecret(env('GOOGLE_CLIENT_SECRET'))
->withRefreshToken(env('GOOGLE_REFRESH_TOKEN'))
->build();

// Replace with your developer token, client customer ID, and user 
agent.
$googleAdsClient = (new GoogleAdsClientBuilder())
->withDeveloperToken(env('GOOGLE_DEVELOPER_TOKEN'))
->withOAuth2Credential($oAuth2Credential)
->build();

$googleAdsServiceClient = 
$googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves all campaigns.
$query = 'SELECT 
campaign.name,campaign_budget.amount_micros,campaign.status,campaign.optimization_score,campaign.advertising_channel_type,

metrics.clicks,metrics.impressions,metrics.ctr,metrics.average_cpc,metrics.cost_micros,campaign.bidding_strategy_type
 
 FROM campaign';
// Issues a search stream request.
/** @var GoogleAdsServerStreamDecorator $stream */
$stream =
$googleAdsServiceClient->searchStream($customer_id, $query);
/* var_dump( $stream->iterateAllElements());
foreach ($stream->iterateAllElements() as $googleAdsRow) {
 
printf(
"Campaign with ID %d and name '%s' was found.%s",
$googleAdsRow->getCampaign()->getId(),
$googleAdsRow->getCampaign()->getName(),
PHP_EOL
);
}
  

die(); */
$budgetResourceName = 
$this->addCampaignBudget($googleAdsClient, $customer_id);
 // Configures the campaign network options.
$networkSettings = new NetworkSettings([
'target_google_search' => true,
'target_search_network' => true,
// Enables Display Expansion on Search campaigns. See
// https://support.google.com/google-ads/answer/7193800 to 
learn more.
'target_content_network' => true,
'target_partner_search_network' => false
]);

$campaignOperations = [];
for ($i = 0; $i < self::NUMBER_OF_CAMPAIGNS_TO_ADD; $i++) {
// Creates a campaign.
// [START add_campaigns_1]
$campaign = new Campaign([
'name' => 'Interplanetary Cruise #' . 
getPrintableDatetime(),
'advertising_channel_type' => 
AdvertisingChannelType::SEARCH,
// Recommendation: Set the campaign to PAUSED when creating 
it to prevent
// the ads from immediately serving. Set to ENABLED once 
you've added
// targeting and the ads are ready to serve.
'status' => CampaignStatus::PAUSED,
// Sets the bidding strategy and budget.
'manual_cpc' => new ManualCpc(),
'campaign_budget' => $budgetResourceName,
// Adds the network settings configured above.
'network_settings' => $networkSettings,
// Optional: Sets the start and end dates.
'start_date' => date('Ymd', strtotime('+1 day')),
'end_date' => date('Ymd', strtotime('+1 

Google  \  Ads  \  GoogleAds  \  Lib  \  V12  \  GoogleAdsException

2022-12-20 Thread Turkmeks DEV
How can ı solve this probleme 
ads_system\vendor\googleads\google-ads-php\src\Google\Ads\GoogleAds\Lib\V12\GoogleAdsExceptionTrait.php
 
: 76

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79
self::$GOOGLE_ADS_FAILURE_BINARY_KEY ) ); } if 
(isset($metadata[self::$GOOGLE_ADS_FAILURE_JSON_KEY])) { throw 
$this->createGoogleAdsException( $exception, 
$statusMetadataExtractor->extractGoogleAdsFailure( 
$metadata, self::$GOOGLE_ADS_FAILURE_JSON_KEY ) ); } } private function 
createGoogleAdsException( ApiException $exception, GoogleAdsFailure 
$googleAdsFailure ) { $optionalArgs = [ 'previous' => 
$exception->getPrevious(), 'metadata' => $exception->getMetadata(), 
'basicMessage' 
=> $exception->getBasicMessage() ]; var_dump($optionalArgs); return new 
GoogleAdsException($exception, $googleAdsFailure, $optionalArgs); } } 

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/07b63528-ffb4-4e6e-89ce-091210865afbn%40googlegroups.com.