Google Ad-Words API - ad extention link for mobile - google-ads-api

During adding site links to campaign feed, I would like to set device preference for mobile to be checked.
How can I do it with ad words API ?
platformOperand.stringValue = "Mobile";//it also can be set for "Desktop"
I tried to do it like this:
ConstantOperand platformOperand = new ConstantOperand();
platformOperand.stringValue = "Mobile";//it also can be set for "Desktop"
platformOperand.type = ConstantOperandConstantType.STRING;
Function platformFunction = new Function();
platformFunction.lhsOperand = new FunctionArgumentOperand[] {
platformRequestContextOperand };
platformFunction.#operator = FunctionOperator.EQUALS;
platformFunction.rhsOperand = new FunctionArgumentOperand[] {
platformOperand };
and then it combined in function with links ids from google service and mutated for campaign feed service.
No exception and link added but when I enter to link edit, "Mobile" option remain unmarked.
Please advise.

I found the answer:
you shuld set devicePreference when you set propertes for FeedItem:
// Create the feed item and operation.
var item = new FeedItem();
item.feedId = siteLinksData.SiteLinksFeedId;
item.attributeValues = new FeedItemAttributeValue[]
{linkTextAttributeValue, linkUrlAttributeValue };
if (value.DeviceType == Device.Mobile)
{
item.devicePreference = new FeedItemDevicePreference();
item.devicePreference.devicePreference = 30001L;
item.devicePreference.devicePreferenceSpecified = true;
}
and this is most important part:
item.devicePreference = new FeedItemDevicePreference();
item.devicePreference.devicePreference = 30001L;
item.devicePreference.devicePreferenceSpecified = true;
if you wondering what the meaning of 30001L, it's device criteria IDs according to adwords API
See https://developers.google.com/adwords/api/docs/appendix/platforms

Related

How to create one Adgroup in multiple campaigns using Google Adwords API?

I am playing with Google Adwords API. I am using the PHP client library.I am intended to create one ad group for multiple campaigns.
I am doing this in a loop and ad group is created for first iteration successfully but then throws an error given below
Help would be appreciated.
If someone wants code I'll provide it as well.
Thanks
I have solved this issue. Actually, I was using the same instance of service for each iteration that was wrong.
$adGroupService = $adWordsServices->get($session,
AdGroupService::class);
$fields =['Id','Name','Status','ServingStatus','AdvertisingChannelType','AdvertisingChannelSubType'];
$campaignService = $adWordsServices->get($session, CampaignService::class);
$adGroupId = 0;
for ($i=0; $i <count($campaignNameArr) ; $i++) {
$operations =[];
$adGroupService = $adWordsServices->get($session, AdGroupService::class); // HERE IS THE LINE OF CODE.
$_collection = self::fetchCampaigns(
$request,
$campaignService,
$fields,
$entriesPerPage,
$pageNo,
$campaignNameArr[$i]
);
if(count($_collection) >0)
{
$flag= true;
foreach ($_collection as $key => $campaign) {
$campaignId = $campaign->getID();
}
}
else
{
echo "No Campaign with name of :". $campaignNameArr[$i];
echo "<br/>";
continue;
}
$msg = 'Created';
echo $campaignId."<br/>";
// Create an ad group with required and optional settings.
$adGroup = new AdGroup();
$adGroup->setCampaignId($campaignId);
// $adGroup->setName($productTitle.' #' . uniqid());
$adGroup->setName($productTitle);
// Set bids (required).
$bid = new CpcBid();
$money = new Money();
$money->setMicroAmount(10000);
$bid->setBid($money);
$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$biddingStrategyConfiguration->setBids([$bid]);
$adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);
// Set additional settings (optional).
$adGroup->setStatus(AdGroupStatus::ENABLED);
// Targeting restriction settings. Depending on the criterionTypeGroup
// value, most TargetingSettingDetail only affect Display campaigns.
// However, the USER_INTEREST_AND_LIST value works for RLSA campaigns -
// Search campaigns targeting using a remarketing list.
$targetingSetting = new TargetingSetting();
$details = [];
// Restricting to serve ads that match your ad group placements.
// This is equivalent to choosing "Target and bid" in the UI.
$details[] = new TargetingSettingDetail(CriterionTypeGroup::PLACEMENT, false);
// Using your ad group verticals only for bidding. This is equivalent
// to choosing "Bid only" in the UI.
$details[] = new TargetingSettingDetail(CriterionTypeGroup::VERTICAL, true);
$targetingSetting->setDetails($details);
$adGroup->setSettings([$targetingSetting]);
// Set the rotation mode.
$rotationMode = new AdGroupAdRotationMode(AdRotationMode::OPTIMIZE);
$adGroup->setAdGroupAdRotationMode($rotationMode);
// Create an ad group operation and add it to the operations list.
$operation = new AdGroupOperation();
$operation->setOperand($adGroup);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;
// Create the ad groups on the server and print out some information for
// each created ad group.
$result = $adGroupService->mutate($operations);
$adGroupId = $adGroup->getId();
foreach ($result->getValue() as $adGroup) {
printf(
"Ad group with name '%s' and ID %d was added.\n",
$adGroup->getName(),
$adGroup->getId()
);
}
}

How we can show "No Data Available" message in RDLC Reports via Resources files

How we can show "No Data Available" message in RDLC Reports via Resources files if no data is found. Currently we are reflecting message from NoRowsMessage property for a table, matrix, or list
(https://technet.microsoft.com/en-us/library/cc645968.aspx).
But we want to show it via Resource files and C# code rather then setting it from Properties of Table. Can anyone please assist. The code (Page_Load) of our control page (.ascx)is mentioned below:
private void Page_Load(object sender, EventArgs e)
{
var presenter = (ReportPresenter)Model;
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.Visible = true;
var rdlcPath = "~/ReportsRDLC/EmployeeData.rdlc";
if(presenter.ReportFilter.GroupOption == Resources.Date)
{
rdlcPath = "~/ReportsRDLC/EmployeeDatebyDate.rdlc";
}
groupOption.SelectedValue = presenter.ReportFilter.GroupOption;
const string DataSetName = "EmployeeDataSet";
reportViewer.LocalReport.ReportPath = HttpContext.Current.Server.MapPath(rdlcPath);
var dataSource = new ReportDataSource(DataSetName, presenter.EmployeeDetails);
reportViewer.AsyncRendering = false;
reportViewer.SizeToReportContent = true;
reportViewer.ShowPrintButton = false;
reportViewer.ShowRefreshButton = false;
reportViewer.ShowToolBar = true;
reportViewer.Height = 600;
reportViewer.Width = 400;
reportViewer.ShowPageNavigationControls = false;
reportViewer.ShowFindControls = false;
reportViewer.ShowZoomControl = false;
reportViewer.LocalReport.DataSources.Add(dataSource);
}
Perhaps you could send the message as a parameter.
You can tell if the report will be empty depending if presenter.EmployeeDetails is empty.
ReportParameter[] myParameters = new ReportParameter[1];
myParameters[0] = new ReportParameter("pEmptyMessage", presenter.EmployeeDetails.Any() ? "No Data Available" : string.Empty);
reportViewer.LocalReport.SetParameters(myParameters);
On your report you can then display this message as you please, using the parameter. You can even place it in a textbox and decide whether to display it based on the value.
I hope this is of use to you.
Edit: I forgot to mention that you should add the report parameter with the correct name to your reporter:
In the reporter you can then use the parameter as followed : [#pEmptyMessage]
=Parameters!pEmptyMessage.Value

How to get LinkedIn Updates detail from it "updateKey"?

I got following JSON from https://api.linkedin.com/v1/people/~/network/updates
(
{
isCommentable = 0;
isLikable = 0;
timestamp = "-1";
updateContent = {
........
};
updateKey = "UPDATE-c2858344-12394303";
updateType = CMPY;
}
,......
)
In above all the array JSON,updateKey is unique like any ID.
I need to show Linkedin Update URL based on this unique updateKey to show it in webview of iOS application.
I try to found this in LinkedIn api But I not found proper solution.
Thanks in advance.

With C# Dev Kit, Invoice Not Appearing In QB

The code seems to run. I don't get any error messages, but an invoice does not appear in QB after I sync. The code is basically this (http://pastebin.com/y7QENxeX) with a few (presumably) minor changes as noted. I'm able to create Accounts and Customers so I believe the basic infrastructure of my app is good. I don't understand why I'm stuck on invoices. I think my customerID is 2. I only have 5 in my company right now. And I think my itemID is 1 as I only have one in QB right now.
Any and all help is greatly appreciated.
Intuit.Ipp.Data.Qbd.PhysicalAddress physicalAddress = new Intuit.Ipp.Data.Qbd.PhysicalAddress();
physicalAddress.Line1 = "123 Main St.";
physicalAddress.Line2 = "Apt. 12";
physicalAddress.City = "Mountain View";
physicalAddress.CountrySubDivisionCode = "CA";
physicalAddress.Country = "USA";
physicalAddress.PostalCode = "94043";
physicalAddress.Tag = new string[] { "Billing" };
Intuit.Ipp.Data.Qbd.InvoiceHeader invoiceHeader = new Intuit.Ipp.Data.Qbd.InvoiceHeader();
invoiceHeader.ARAccountId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "37" };
invoiceHeader.ARAccountName = "Accounts Receivable";
// original code : invoiceHeader.CustomerId = new IdType() { idDomain = idDomainEnum.NG, Value = "3291253" };
invoiceHeader.CustomerId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "2" };
invoiceHeader.Balance = (decimal)100.00;
invoiceHeader.BillAddr = physicalAddress;
invoiceHeader.BillEmail = "detroit#tigers.com";
invoiceHeader.CustomerName = "Detroit Tigers";
invoiceHeader.DocNumber = "1234567";
invoiceHeader.DueDate = DateTime.Now;
invoiceHeader.ShipAddr = physicalAddress;
invoiceHeader.ShipDate = DateTime.Now;
invoiceHeader.TaxAmt = (decimal)5;
invoiceHeader.TaxRate = (decimal).05;
invoiceHeader.ToBeEmailed = false;
invoiceHeader.TotalAmt = (decimal)105.00;
List<Intuit.Ipp.Data.Qbd.InvoiceLine> listLine = new List<Intuit.Ipp.Data.Qbd.InvoiceLine>();
//Loop for multiple invoice lines could be added here
Intuit.Ipp.Data.Qbd.ItemsChoiceType2[] invoiceItemAttributes = { Intuit.Ipp.Data.Qbd.ItemsChoiceType2.ItemId, Intuit.Ipp.Data.Qbd.ItemsChoiceType2.UnitPrice, Intuit.Ipp.Data.Qbd.ItemsChoiceType2.Qty };
// original code : object[] invoiceItemValues = { new IdType() { idDomain = idDomainEnum.QB, Value = "5" }, new decimal(33), new decimal(2) };
object[] invoiceItemValues = { new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "1" }, new decimal(33), new decimal(2) };
var invoiceLine = new Intuit.Ipp.Data.Qbd.InvoiceLine();
invoiceLine.Amount = 66;
invoiceLine.AmountSpecified = true;
invoiceLine.Desc = "test " + DateTime.Now.ToShortDateString();
invoiceLine.ItemsElementName = invoiceItemAttributes;
invoiceLine.Items = invoiceItemValues;
invoiceLine.ServiceDate = DateTime.Now;
invoiceLine.ServiceDateSpecified = true;
listLine.Add(invoiceLine);
Intuit.Ipp.Data.Qbd.Invoice invoice = new Intuit.Ipp.Data.Qbd.Invoice();
invoice.Header = invoiceHeader;
invoice.Line = listLine.ToArray();
Intuit.Ipp.Data.Qbd.Invoice addedInvoice = commonService.Add(invoice);
Chris
You need to read the following information about how QuickBooks for Windows Sync Manager works, how to see if Sync ran correctly, if objects are in an errored state and how to resolve. It could be any number of things. Once a record is inserted into the cloud, it asynchronously downloads to QuickBooks on the desktop, at which time business logic is applied and records are matched from the cloud to the desktop. If there is an issue, sync manager will show a record of the object that failed, why it failed and the object will now be in an error state.
At this point you can review the error and take steps to fix, like revert or update and resubmit. Links to the documentation below.
QuickBooks Sync Manager
Data Sync
Objects in Errored State
Sync Activity
Sync Status
regards
Jarred

Get all clientID from MCC adwords account by adwordsAPI

I want to retrieve all clientID from my MCC account. I'm using this code
AdWordsUser user = new AdWordsUser(adwordsPropertyService.getEmail(), adwordsPropertyService.getPassword(),
null, adwordsPropertyService.getUseragent(), adwordsPropertyService.getDeveloperToken(),
adwordsPropertyService.getUseSandbox());
InfoServiceInterface infoService = user.getService(AdWordsService.V201109.INFO_SERVICE);
InfoSelector selector = new InfoSelector();
selector.setApiUsageType(ApiUsageType.UNIT_COUNT_FOR_CLIENTS);
String today = new SimpleDateFormat("yyyyMMdd").format(new Date());
selector.setDateRange(new DateRange(today, today));
selector.setIncludeSubAccounts(true);
ApiUsageInfo apiUsageInfo = infoService.get(selector);
for (ApiUsageRecord record : apiUsageInfo.getApiUsageRecords()) {
......
But apiUsageInfo.getApiUsageRecords return my only some clientId.
Have you any suggests?
My Answer will be helpful for PHP Developers
I am using v201502(php), You will get all account details from ManagedCustomerService api. Please refer the following URL https://developers.google.com/adwords/api/docs/reference/v201502/ManagedCustomerService
This is the sample code i used,
function DisplayAccountTree($account, $link, $accounts, $links, $depth) {
print str_repeat('-', $depth * 2);
printf("%s, %s\n", $account->customerId, $account->name);
if (array_key_exists($account->customerId, $links)) {
foreach ($links[$account->customerId] as $childLink) {
$childAccount = $accounts[$childLink->clientCustomerId];
DisplayAccountTree($childAccount, $childLink, $accounts, $links,
$depth +1);
}
}
}
function GetAccountHierarchyExample(AdWordsUser $user) {
// Get the service, which loads the required classes.
$user->SetClientCustomerId('xxx-xxx-xxxx');
$managedCustomerService =
$user->GetService('ManagedCustomerService');
// Create selector.
$selector = new Selector();
// Specify the fields to retrieve.
$selector->fields = array('CustomerId', 'Name');
// Make the get request.
$graph = $managedCustomerService->get($selector);
// Display serviced account graph.
if (isset($graph->entries)) {
// Create map from customerId to parent and child links.
$childLinks = array();
$parentLinks = array();
if (isset($graph->links)) {
foreach ($graph->links as $link) {
$childLinks[$link->managerCustomerId][] = $link;
$parentLinks[$link->clientCustomerId][] = $link;
}
}
// Create map from customerID to account, and find root account.
$accounts = array();
$rootAccount = NULL;
foreach ($graph->entries as $account) {
$accounts[$account->customerId] = $account;
if (!array_key_exists($account->customerId, $parentLinks)) {
$rootAccount = $account;
}
}
// The root account may not be returned in the sandbox.
if (!isset($rootAccount)) {
$rootAccount = new Account();
$rootAccount->customerId = 0;
}
// Display account tree.
print "(Customer Id, Account Name)\n";
DisplayAccountTree($rootAccount, NULL, $accounts, $childLinks, 0);
} else {
print "No serviced accounts were found.\n";
}
}
GetAccountHierarchyExample($user);
SetClientCustomerId will be the parent ID of your all accounts, It will be appeared near the Sign Out button of you google AdWords account, Please see the attached image
I hope this answer will be helpful, Please add your comments below if you want any further help
If you need just the list of clientCustomerIds, try ServicedAccountService.
Here is a code example that shows how this may be done.
Next time, you might also want to consider asking the question on the official forum for AdWords API: https://groups.google.com/forum/?fromgroups#!forum/adwords-api

Resources