Getting Google Ads API keyword_plan_idea_error: The input has an invalid value - google-ads-api

$requestOptionalArgs = [];
$requestOptionalArgs['keywordSeed'] = new KeywordSeed(['keywords' => $keywords]);
$keywordPlanIdeaServiceClient->generateKeywordIdeas([
'language' => ResourceNames::forLanguageConstant(1000), // English
'customerId' => $customerId,
'geoTargetConstants' => $geoTargetConstants,
'keywordPlanNetwork' => KeywordPlanNetwork::GOOGLE_SEARCH
] + $requestOptionalArgs);
The above code is working fine if the $keywords array size is not more than 20. If I add the 21st keyword to the $keywords array then it's throwing the below error.
keyword_plan_idea_error: The input has an invalid value.

Related

Undefined Index on Empty Form

This error is only on my local development system where errors are enabled and otherwise the programming works fine but how can I get rid of the error?
This snippet is part of the code that generates a form semi-dynamically from the column names and the error is coming from addslashes($row[$val]) when an empty form is initially opened. Once the form has been populated with data, the error is gone but until then, each field gives the error at the top of the page.
// Build WHERE clause to prevent errors when loading page with no values
$Where = (isset($PostID)) ? "WHERE `ID`='$PostID'" : "";
// Open record for viewing
$sqlView = "SELECT * FROM $TableName $Where";
$row = DBConnect($sqlView, "Select", $siteDB);
// Attempt to eliminate Undefined Index errors
if (!is_array($row)) $row = [];
// Get array of column names from tableaddslashes($row[$val])
$FieldNames = ListColumns($TableName, $siteDB);
// Create variable variables from table column names and populate on post or from existing entry
foreach ($FieldNames as $val) :
$$val = (isset($_POST[$val])) ? safeData($_POST[$val]) : addslashes($row[$val]);
endforeach;
$FieldNames, in this case, contains:
Array
(
[0] => ID
[1] => PageTitle
[2] => MenuTitle
[3] => PageText
[4] => DateUpdated
[5] => ShowPage
)
The actual errors are:
Notice: Undefined index: ID in /var/www/html/form.php on line 88
Notice: Undefined index: PageTitle in /var/www/html/form.php on line 88
Notice: Undefined index: MenuTitle in /var/www/html/form.php on line 88
Notice: Undefined index: PageText in /var/www/html/form.php on line 88
Notice: Undefined index: DateUpdated in /var/www/html/form.php on line 88
Notice: Undefined index: ShowPage in /var/www/html/form.php on line 88
Your $row is empty array:
$$val = (isset($_POST[$val])) ? safeData($_POST[$val])
: (isset($row[$val]) ? addslashes($row[$val]) : '');

How to handle the result of a list of future with ReasonML?

I am trying to go over a list of items, cache the URL and then update the URL in the list before drawing it.
However I don't seems to be able to do so.
Any idea?
external cache: option(string) => Js.Promise.t({. "uri": string, "filePath": string }) = "get";
let items = result##data##data->Option.getWithDefault([||]);
let cachedUri = items
->Belt.Array.map(
item =>
cache(item##hosted_video_url)
->FutureJs.fromPromise(Js.String.make)
->Future.flatMapOk(cachedObj => (
{. "hosted_video_url": cachedObj##uri }
)
))
->Belt.Array.toList
->Future.all;
The idea is that you cannot exit a future, so you need to update the state inside the future thing rather than trying to get an equivalent of an asyncio.gather or something similar.
I changed:
setVerticalData(_ => {items-> Js.Array2.sortInPlaceWith((a, b) => {...})});
with
items
->List.fromArray;
->List.map(item =>
cache(item##hosted_video_url)
->FutureJs.fromPromise(Js.String.make)
)
->Future.all
->Future.map(cachedList => {
setVerticalData(_ => {items: cachedList})
})

How can I access an array inside a hash?

I have a hash within an array:
values = {}
values.merge!(name => {
"requested_amount" => #specific_last_pending_quota.requested_amount,
"granted" => #specific_last_pending_quota.granted,
"pending_final" => pending_final
})
#o_requests[request.receiving_organization][request.program_date][:data] = values
I send it to the view and then when I get it so:
= quota[:data].inspect
# {"theme"=>{"requested_amount"=>2, "granted"=>false, "pending_final"=>0}}
I want to fetch the object like this:
= quota[:data]["theme"].inspect
But I got this error
can't convert String into Integer
I guess quota[:data] may return array of hash
Try:
= quota[:data][0]["theme"]
Here I tried case to get same error and check:
> h[:data]
#=> [{"theme"=>{"requested_amount"=>2, "granted"=>false, "pending_final"=>0}}]
> h[:data]["theme"]
TypeError: no implicit conversion of String into Integer
from (irb):10:in `[]'
from (irb):10
from /home/ggami/.rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'
> h[:data][0]["theme"]
#=> {"requested_amount"=>2, "granted"=>false, "pending_final"=>0}
Try convert it to proper hash I guess it should work fine.
values = {}
values.merge!(name => {:requested_amount => #specific_last_pending_quota.requested_amount, :granted => #specific_last_pending_quota.granted, :pending_final => pending_final})
#o_requests[request.receiving_organization][request.program_date][:data] = values

Adding to and deleting hashes

I am trying to create the back-end for a calendar system. The calendar is just a list of Events. I am trying to organise this in to a reasonable JSON response. The structure I am looking to replicate would be something like this
eventsList = [
{ 'year' => 2014,
'events' => [{event data hash 1},
{event data hash 2}]
},
{ 'year' => 2015,
'events' => [{event data hash 1},
{event data hash 2}]
}
]
I am having trouble trying to add events to the right array. Below I have Event.all and I am trying to sort the list.
events = Event.all
eventList = []
events.each do |event|
#Creates a hash of the current event info
eventInfo = {'description' => event.description, 'startdate' => event.startdate}
eventMonthNumber = event.startdate.strftime('%m').to_i
eventMonthName = event.startdate.strftime('%B')
eventYearNumber = event.startdate.strftime('%Y').to_i
# Adds year to eventList if it isn't present
unless eventList.include?(eventYearNumber)
eventList << {'year' => eventYearNumber, 'events' => []}
end
# Tries to find current year hash in array and add to event key
currentYear = eventList.select {|event| event['year'] == eventYearNumber}
currentYear['events'] << eventInfo
end
I get the error no implicit conversion of String into Integer. I am not entirely sure whether the eventList.select is the correct way to go about this
Although I have moved away from this current structure the change that made it work was swapping out
eventList.select
For
eventList.detect
Select returns an array (?) And detect returns one item.

How to: parse a string 'mm/yyyy' into a date in PHP5.3?

I come from Java & C# worlds, and just wondering how do I parse a string formatted as mm/yyyy into a date in PHP 5.3.
I've tried with the following:
date_parse_from_format('mm/yyyy', '05/2013');
Then the returned array complains with errors:
[2] => Unexpected data found.
[5] => The separation symbol could not be found
[7] => Data missing
How to parse to date a string formatted as mm/yyyy in PHP 5.3?
Here is the complete var_dump:
Array
(
[year] => 2013
[month] => 20
[day] =>
[hour] =>
[minute] =>
[second] =>
[fraction] =>
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 3
[errors] => Array
(
[2] => Unexpected data found.
[5] => The separation symbol could not be found
[7] => Data missing
)
[is_localtime] =>
)
Use 'm/Y' instead of 'mm/yyyy'. Look at the date() function for details.
date_parse_from_format('m/Y', '05/2013');
What to do next...first of all I'd use Object oriented style:
$date = DateTime::createFromFormat('m/Y', '05/2013');
// 2013-05
echo $date->format('Y-m');
// 1369946144 UNIX timestamp
echo $timestamp = $date->format('U');
// 2013-05 using date(), procedural style
echo date('Y-m', $timestamp );

Resources