How can I add new placement (website, for example www.example.com) in AdGroup using AdWords API?
I have found
AdGroupCriterionService->mutate,
but I need to know ID of website
$adGroupCriterion->criterion = new Criterion($criterionId);
So my question:
How I can found ID for any website or exist another way to add new Placement in AdGroup?
I found an answer:
$adGroupService = $user->GetService('AdGroupCriterionService', 'v201509');
$AdGroupCriterionOperation = new AdGroupCriterionOperation();
$AdGroupCriterionOperation->operator = 'ADD';
$AdGroupCriterion = new BiddableAdGroupCriterion();
$AdGroupCriterion->adGroupId = $adGroupId;
$AdGroupCriterion->criterionUse = 'BIDDABLE';
$AdGroupCriterion->AdGroupCriterionType = 'PLACEMENT';
$Placement = new Placement();
$Placement->id = null;
$Placement->CriterionType = 'PLACEMENT';
$Placement->type = 'PLACEMENT';
$Placement->url = $url;
$AdGroupCriterion->criterion = $Placement;
$AdGroupCriterionOperation->operand = $AdGroupCriterion;
$operations = array($AdGroupCriterionOperation);
// Make the mutate request.
$result = $adGroupService->mutate($operations);
Related
I used to upload offline conversion using following code in v201809 version as provided at
https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201809/Remarketing/UploadOfflineConversions.php
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->withClientCustomerId($customerid)->enablePartialFailure()->build();
$adWordsServices = new AdWordsServices();
$offlineConversionService = $adWordsServices->get($session, OfflineConversionFeedService::class);
$conversionName="OfflineConv";
$feed = new OfflineConversionFeed();
$feed->setConversionName($conversionName);
$feed->setConversionTime($conversionTime);
$feed->setConversionValue($conversionValue);
$feed->setGoogleClickId($gclid);
$offlineConversionOperation = new OfflineConversionFeedOperation();
$offlineConversionOperation->setOperator(Operator::ADD);
$offlineConversionOperation->setOperand($feed);
$offlineConversionOperations = [$offlineConversionOperation];
$result = $offlineConversionService->mutate($offlineConversionOperations);
Now I am upgrading to V9, I have used the code as provided at
https://github.com/googleads/google-ads-php/blob/main/examples/Remarketing/UploadOfflineConversion.php
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
//$conversionName="OfflineConv";
$conversionName = ConversionActionType::WEBPAGE;
$clickConversion = new ClickConversion([
'conversion_action' => ResourceNames::forConversionAction($customerId, $conversionName),
'gclid' => $gclid,
'conversion_value' => $conversionValue,
'conversion_date_time' => $conversionTime,
'currency_code' => 'USD'
]);
$conversionUploadServiceClient = $googleAdsClient->getConversionUploadServiceClient();
$result = $conversionUploadServiceClient->uploadClickConversions($customerid, [$clickConversion], true);
The problem is when we set $conversionName="OfflineConv"; we get following error.
Resource name 'customers/9025381111/conversionActions/OfflineConv' is malformed: expected 'customers/{customer_id}/conversionActions/{ConversionType.conversion_type_id}'., at conversions[0].conversion_action
and when we set $conversionName = ConversionActionType::WEBPAGE; we get following error.
This customer does not have an import conversion action that matches the conversion action provided., at conversions[0].conversion_action
Can someone help me?
Conversion Name must match the conversion action that you've already set up in your account. You're passing the enum value for the type.
It should be something like $conversionName = "OfflineConversions"
where "OfflineConversions" is exactly the name of the conversion in the conversions section of the web UI.
ConversionName has been removed from V9, use $conversionActionId as in example on github.
You need to try use parameter ctId from url your "OfflineConversions" in Google Ads UI as $conversionActionId.
Or try the solution from here.
For your example, replace this
$conversionName = ConversionActionType::WEBPAGE;
on this
$conversionName = {ctId from url};
You need to first create a click conversion
click_conversion = adwords_client.get_type("ClickConversion")
conversion_action_service = adwords_client.get_service('ConversionActionService')
click_conversion.conversion_action = (
conversion_action_service.conversion_action_path(
customer_id, conversion_action_id
)
)
The conversion_action_id is equivalent to conversion_name of previous version.
You can find the id using following snippet
ads: GoogleAdsServiceClient = self.adwords_client.get_service('GoogleAdsService')
pages = ads.search(query="SELECT conversion_action.id, conversion_action.name FROM conversion_action where conversion_action.name={conversion_name}", customer_id={customer_id})
for page in pages:
print(page.conversion_action)
Then you upload the conversion
click_conversion.gclid = gclid
click_conversion.conversion_value = conversion_value
click_conversion.conversion_date_time = conversion_time
click_conversion.currency_code = currency_code
conversion_upload_service = self.adwords_client.get_service("ConversionUploadService")
request = self.adwords_client.get_type("UploadClickConversionsRequest")
request.customer_id = customer_id
request.conversions.append(click_conversion)
request.partial_failure = True
conversion_upload_response = (
conversion_upload_service.upload_click_conversions(
request=request,
)
)
uploaded_click_conversion = conversion_upload_response.results[0]
print(
f"Uploaded conversion that occurred at "
f'"{uploaded_click_conversion.conversion_date_time}" from '
f'Google Click ID "{uploaded_click_conversion.gclid}" '
f'to "{uploaded_click_conversion.conversion_action}"'
)
I'm trying to do the same as
query = new CB.CloudQuery('Class');
query.include('columnName');
But using CloudSearch, SearchQuery or SearchFilter. Is it possible? For example:
var cs = new CB.CloudSearch(Class);
cs.searchFilter = new CB.SearchFilter();
cs.searchQuery = new CB.SearchQuery();
cs.include('columnName');
// or
cs.searchQuery.include('columnName');
Thanks!
It's actually, cs.searchFilter.include('columnName');
I am using the quickbooks sdk to connect with a quickbook online account. I am able to connect a get data like customers and invoice without a problem. But I am unable to create an invoice using the sdk. Here is my code:
$token = unserialize($_SESSION['token']);
$requestValidator = new OAuthRequestValidator(
$token['oauth_token'], $token['oauth_token_secret'], OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$realmId = $_SESSION['realmId'];
$serviceType = $_SESSION['dataSource'];
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
$dataService = new DataService($serviceContext);
//create an invoice
$invoiceObj = new IPPInvoice();
$invoiceObj->CustomerRef = 5;
$invoiceObj->Amount = 12.00;
$invoiceObj->DocNumber = 9999;
$invoiceObj->TaxnDate = "2014-05-01";
$Line = new IPPline();
$Line->DetailType ='SalesItemLineDetail';
//$Line->Amount = 10;
$Line->setDescription = 'Test description goes here.';
$saleItemLineDetail = new IPPSalesItemLineDetail();
$saleItemLineDetail->ItemRef = 1;
$saleItemLineDetail->Quantity = 1;
$saleItemLineDetail->UnitPrice = 10.00;
$line->SalesItemLineDetail = $saleItemLineDetail;
$invoiceObj->Line = $line;
$resultingInvoiceObj = $dataService->Add($invoiceObj);
When a run this an invoice isn't created and I get this error:
Fatal error: Uncaught IdsException: [0]: 2014-05-02 17:26:08 - /home/randy/test_apps/v3-php-sdk-2.0.4/DataService/DataService.php - 340 - CheckNullResponseAndThrowException - Response Null or Empty thrown in /home/randy/test_apps/v3-php-sdk-2.0.4/Core/CoreHelper.php on line 95
I don't think the Line data is getting added correctly. How do I correctly add line data or is it something else?
Thanks
You have to pass customer id as string as follows
$invoiceObj->CustomerRef = 5;
Below is working sample code
Sample Code
In WP7.5(Mango), is it possible to add a contact to the phone book through code?
Currently there is no API to save the contact directly from the code as it deals with user data.
But you can save the contact from your application by using the SaveContactTask with user intervention.
you can use the following code
SaveContactTask saveContactTask = new SaveContactTask();
saveContactTask.Company = "WindowsPhoneGeek";
saveContactTask.FirstName = "John";
saveContactTask.LastName = "Smith";
saveContactTask.HomePhone = "000-125-547";
saveContactTask.HomeAddressCity = "London";
saveContactTask.HomeAddressCountry = "UK";
saveContactTask.HomeAddressStreet = "123 Bake Road";
saveContactTask.HomeAddressZipCode = "W11 2BQ";
saveContactTask.JobTitle = "Software Developer";
saveContactTask.Show();
You can refer this blog for the more information.
Yes there is. You should use the new API,
using Microsoft.Phone.Tasks;
SaveContactTask newContact = new SaveContactTask();
newContact.FirstName = "x";
newContact.LastName = "Y";
newContact.MobilePhone = "0123456789";
newContact.Show();
Also refer this http://msdn.microsoft.com/en-us/library/hh202995(v=vs.92).aspx
I am trying to connect to the FedEx shipping webservice v8.
Everything works fine when I only have one RequestedPackageLineItems set. When I add two items I get the following error.
"Invalid package count or invalid package sequence number."
My Code is as follows
ProcessShipmentRequest request = CreatePendingShipmentRequest();
ShipService service = new ShipService();
ProcessShipmentReply reply = service.processShipment(request);
...
private static ProcessShipmentRequest CreatePendingShipmentRequest()
{
ProcessShipmentRequest request = new ProcessShipmentRequest();
request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.UserCredential.Key = "XXX";
request.WebAuthenticationDetail.UserCredential.Password = "XXX";
request.ClientDetail = new ClientDetail();
request.ClientDetail.AccountNumber = "XXX";
request.ClientDetail.MeterNumber = "XXX";
request.TransactionDetail = new TransactionDetail();
request.TransactionDetail.CustomerTransactionId = "*** Ground Domestic Shipping Request v8 using C# ***";
request.Version = new VersionId();
//Inside this method I set request.RequestedShipment.PackageCount = "2";
SetShipmentDetails(request);
SetPackageLineItems(request);
return request;
}
private static void SetPackageLineItems(ProcessShipmentRequest request)
{
request.RequestedShipment.RequestedPackageLineItems = new RequestedPackageLineItem[2];
request.RequestedShipment.RequestedPackageLineItems[0] = new RequestedPackageLineItem();
request.RequestedShipment.RequestedPackageLineItems[0].SequenceNumber = "1";
request.RequestedShipment.RequestedPackageLineItems[0].Weight = new Weight();
request.RequestedShipment.RequestedPackageLineItems[0].Weight.Value = 50.0M;
request.RequestedShipment.RequestedPackageLineItems[0].Weight.Units = WeightUnits.LB;
request.RequestedShipment.RequestedPackageLineItems[0].ItemDescription = "Item";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions = new Dimensions();
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Length = "108";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Width = "5";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Height = "5";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Units = LinearUnits.IN;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences = new CustomerReference[3];
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].CustomerReferenceType = CustomerReferenceType.CUSTOMER_REFERENCE;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].Value = "[LOT NUMBER]";
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].CustomerReferenceType = CustomerReferenceType.INVOICE_NUMBER;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].Value = "45646";
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].CustomerReferenceType = CustomerReferenceType.P_O_NUMBER;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].Value = "456446";
request.RequestedShipment.RequestedPackageLineItems[1] = new RequestedPackageLineItem();
request.RequestedShipment.RequestedPackageLineItems[1].SequenceNumber = "2";
request.RequestedShipment.RequestedPackageLineItems[1].Weight = new Weight();
request.RequestedShipment.RequestedPackageLineItems[1].Weight.Value = 50.0M;
request.RequestedShipment.RequestedPackageLineItems[1].Weight.Units = WeightUnits.LB;
request.RequestedShipment.RequestedPackageLineItems[1].ItemDescription = "Item";
....
}
Found out how to do this.
In order to get multiple shipping labels into one pdf the process is as follows.
Create a request
Fill in the shipping info
Post and get a reply.
Save that replay and the byte array and MasterShippingID
Create a new request and assign the master shipping id to it.
Added shipping weight and dimensions
Post and get reply
Save byte array with the other
Continue until all shipments are generated (max 200 per master shipping id)
Merge all the pdfs returned from FedEx into one pdf.
Do a happy dance.
A simpler approach, (though there is a cost) is the Shiprush SDK. It lets you build a single XML block and let ShipRush do all the funny stuff with fedex (or whoever).
They also support their tool.