I'm using the code autogenerated by facebook to try and connect to the marketing API to get campaign stats. In doing so, I'm getting:
Uncaught FacebookAds\Http\Exception\AuthorizationException: (#100) results, actions:like, video_play_actions:video_view, video_avg_time_watched_actions:video_view, unique_actions:link_click are not valid for fields param.
$fields = array(
'results',
'reach',
'actions:like',
'video_play_actions:video_view',
'video_avg_time_watched_actions:video_view',
'unique_actions:link_click',
);
var_dump($fields);
$params = array(
'level' => 'campaign',
'filtering' => array(array('field' => 'campaign.delivery_info','operator' => 'IN','value' => array('active'))),
'breakdowns' => array(),
'time_range' => array('since' => '2017-05-19','until' => '2019-05-19'),
);
echo json_encode((new AdAccount($ad_account_id))->getInsights(
$fields,
$params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);
Above I used campaign.delivery_info per this answer. I've also tried (per the auto-generated code):
'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('active')))
Seems you are asking for old values field, try this:
$fields = array(
'reach',
'actions',
'video_play_actions',
'video_avg_time_watched_actions',
'outbound_clicks',
);
Hope this help
NB: results field is not available
I'm having a problem with an Elastica QueryBuilder exact search in a Symfony app. The Elastica version is 2.1, which depends on Elasticsearch 1.5.2. I'm searching an index where one of the fields is mapped as
majors:
type: string
index : not_analyzed
The field is a student's major that can have one or more words, such as "Ancient History".
The query is set up like this:
/** #var ElasticaFactory $ef */
protected $ef;
public function __construct(ElasticaFactory $ef)
{
$this->ef = $ef;
}
$query = $this->ef->createQuery();
$qb = $this->ef->createQueryBuilder();
$bool = $qb->filter()->bool();
$query->setQuery(
$qb->query()->filtered(
$qb->query()->term(),
$bool->addShould(
$qb->filter()->term(
array('majors' => $params['majors'])
)
)
)
);
When I run this query, I get a SearchPhaseExecutionException error. The full text of the error message is here.
Stack trace shows the full contents of the request:
Client ->request ('students/_search', 'GET', array('query' => array('filtered' => array('query' => array('term' => array()), 'filter' => array('bool' => array('should' => array(array('term' => array('majors' => 'Ancient Studies')))))))), array('from' => '0', 'size' => '10'))
in /vagrant/persona/vendor/ruflin/elastica/lib/Elastica/Search.php at line 455
When I set up the query as a "match" below, it works with no errors:
$query->setQuery(
$qb->query()->filtered(
$qb->query()->match('majors', $params['majors']),
$bool
)
);
However, a match query returns too many irrelevant results. I need specifically an exact search query.
Next, in order to eliminate any issues with Elastica, I converted the query into a raw ES query, like this:
$query->setRawQuery(
array(
'query' => array(
'filtered' => array(
'query' => array(
'term' => array()),
'filter' => array(
'bool' => array(
'should' => array(
array(
'term' => array(
'majors' => 'Art History'
)
)
)
)
)
)
)
)
);
This gave me the same error message as quoted above. Looks like there is a problem with the query itself, and not with Elastica.
When I rearranged the query to exactly follow the documentation as below, it returned no results, even though matching records were present
$query->setRawQuery(
array(
'query' => array(
'filtered' => array(
'filter' => array(
'term' => array(
'majors' => 'Art History'
)
)
)
)
)
);
Any help would be appreciated!
I have the following code in my laravel controller file.
$j_decode->$data['_kfdTourDate']->available = ($j_decode->$data['_kfdTourDate']->available+$totalincrement);
and I am getting the following error.
ErrorException in BookingsController.php line 325: Array to string
conversion in BookingsController.php line 325 at
HandleExceptions->handleError('8', 'Array to string conversion',
'D:\XAMPP\htdocs\lara\app\Http\Controllers\BookingsController.php',
'325', array('request' => object(Request), 'id' => '0', 'rules' =>
array(), 'validator' => object(Validator), 'data' => array('_kpnID' =>
'153290', '_kfnTourID' => '2', '_kfdTourDate' => '2017-03-16',
'nAdults' => '2', 'nChildren' => '1', 'nInfants' => '0', 'nBabies' =>
'2', 'nFOC' => '2', 'nPriceAdult' => '74.25', 'nPriceChild' => '49.5',
'nPriceInfant' => '0', 'nPriceBaby' => '0', 'nTotalPrice' => '148.5',
'tGuestName' => 'Yuhiko Nishioka', 'tGuestOrigin' => 'Unknown',
'tEnquirySourceWhat' => 'Unknown', 'tStatus' => 'Confirmed',
'_kfnAgentID' => '0', '_kfnPersonID' => '0', '_kfnInvoiceID' => '0',
'nAgentCommissionPercent' => '0', 'nDiscount_percent' => '0',
'nDiscount_fixed' => '0', 'tNotes' => '4WD Tour package/Rezdy, applied
discount', 'tInitials' => 'JD', 'CreatedOn' => '2017-01-21 15:08:00',
'ModifiedOn' => '2017-01-21 15:10:00', 'tTicketNumber' => 'Rezdy',
'_kfnOrganisationID' => '0'), 'schedule' => object(Collection),
'j_decode' => object(stdClass), 'update_id_data' => object(stdClass),
'totalincrement' => '3')) in BookingsController.php line 325
Interesting part that it's working on the linux server when I upload it to my host. I have PHP Version 7.0.13 on localhost and PHP Version 5.6.30 on the server.
How can this line cause an Array to string conversion error?
I am not willing to downgrade my php version on localhost as I have other codes that php5 is not supporting.
The whole code in controller:
$rules = $this->validateForm();
$validator = Validator::make($request->all(), $rules);
if ($validator->passes()) {
$data = $this->validatePost( $request );
$schedule = DB::table('schedule')
->where('id','=',$data['_kfnTourID'])
->get();
if(isset($_SESSION['bookingiddata']))
{
print_r ($j_decode= json_decode($schedule[0]->data));
$update_id_data = json_decode($_SESSION['bookingiddata']);
$totalincrement = $update_id_data->nAdults+$update_id_data->nChildren+$update_id_data->nInfants+$update_id_data->nFOC;
//$j_decode->$data['_kfdTourDate']->available = ($j_decode->$data['_kfdTourDate']->available+$totalincrement);
$j_decode->$data['_kfdTourDate']['available'] = ($j_decode->$data['_kfdTourDate']['available']+$totalincrement);
($j_decode->$data)['_kfdTourDate']->status = "available";
Also print_r $j_encode = json_encode($j_decode); prints me the following
{"2017-02-13":{"available":1,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"available"},"2017-02-14":{"available":1,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"available"},"2017-02-08":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-12":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-10":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-15":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-16":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"}...
well, as mentioned here
in php 5.6.3 , it's allowed to use this expression:
echo $json_decode->$data['_kfdTourDate']->available;
so , you are trying to access the value of $data['_kfdTourDate'] which is element in $json_decode object
for example: https://3v4l.org/i9Q7p
in php 7,
Indirect access to variables, properties, and methods will now be
evaluated strictly in left-to-right order, as opposed to the previous
mix of special cases. The table below shows how the order of
evaluation has changed.
so, the interpreter will interpret this code as follow:
echo $json_decode->$data['_kfdTourDate']->available;
// first , give me the value $json_decode->$data,
// then choose the _kfdTourDate key
and to solve this, you need to :
echo $json_decode->{$data['_kfdTourDate']}->available;
to tell php that $data['_kfdTourDate'] is just a value;
There were some order-of-operations changes in PHP7 (see Changes to the handling of indirect variables, properties, and methods). I suspect you might need to mess around with some parentheses within $j_decode->$data['_kfdTourDate']->available to make it evaluate in the order you want.
I created this array of objects:
$ad_1 = new AdUnit(array('id' => '1', 'name' => 'Ad_1', 'description' => 'great ad', 'code' => 'alpha', 'widget_id' => '123'));
$ad_2 = new AdUnit(array('id' => '2', 'name' => 'Ad_2', 'description' => 'good ad', 'code' => 'delta', 'widget_id' => '456'));
$ad_3 = new AdUnit(array('id' => '3', 'name' => 'Ad_3', 'description' => 'bad ad', 'code' => 'sigma', 'widget_id' => '789'));
$adUnitArr = array($ad_1, $ad_2, $ad_3);
and i want to check that a random ad i got from a function exists in the array. the code to get the ad looks like this:
$fixture = new AdGroup();
$fixture->setAds($adUnitArr);
$randad = $fixture->getRandomAd();
now i want to check if the array contains the random ad i received, what i was able to do like this:
$this->assertEquals(in_array($randad, $adUnitArr), 1); //check if ad in array
but my question is, is there an assert or some other way to check this thing better than the way i did it?? i tried using assertArrayHasKey but i got the following error:
PHPUnit_Framework_Exception: Argument #1 (No Value) of PHPUnit_Framework_Assert::assertArrayHasKey() must be a integer or string
any idea please? thx
Try the assertContains method:
$this->assertContains( $randad, $adUnitArr );
Can anyone explain how to use the AWS PHP SDK to log the metric in the style like the above screen.
I use the following PHP code but the select menu is showing "ELB: AvaliabiltyZone", how to make it show "Aggregated by AvaliabiltyZone"? What is the logic used here?
$response = $cw->put_metric_data("ELB", array(
array(
"MetricName" => "Latency",
"Dimensions" => array(
array("Name" => "AvaliabiltyZone" , "Value" => "us-east-1c")
),
"Timestamp" => "now",
"Value" => 1,
"Unit" => "None"
),
));
AvaliabiltyZone
You misspelled "AvailabilityZone"
This maybe won't answer the question, but it might fix some things...
$cw = new AmazonCloudWatch();
$cw->set_region('monitoring.'.$region.'amazonaws.com');
$res1 = $CW->put_metric_data('Sys/RDS' ,
array(array('MetricName' => 'Uptime' ,
'Dimensions' => array(array('Name' => 'AvaliabiltyZone',
'Value' => 'us-east-1c')),
'Value' => $Uptime,
'Unit' => 'Seconds')));
Click Here