Adobe insights api not giving data for few metrics - php

When I run reports in adobe experience cloud for few metrics with page dimension, all metrics are coming correctly, but when I am trying to pull same data via api, few revenue metrics(e.g carts,orders,cartadditions,productinstances) are coming as zero.
I am using curl request to fetch data with access token generated from JWT (Service Account) Authentication.
Here is the my array for post request -
Array
(
[rsid] => XXX
[dimension] => variables/page
[globalFilters] => Array
(
[0] => Array
(
[type] => dateRange
[dateRange] => 2022-04-01T00:00:00.000/2022-04-02T00:00:00.000
)
)
[metricContainer] => Array
(
[metrics] => Array
(
[0] => Array
(
[id] => metrics/pageviews
)
[1] => Array
(
[id] => metrics/visitors
)
[2] => Array
(
[id] => metrics/exits
)
[3] => Array
(
[id] => metrics/bounces
)
[4] => Array
(
[id] => metrics/entries
)
[5] => Array
(
[id] => metrics/carts
)
[6] => Array
(
[id] => metrics/orders
)
[7] => Array
(
[id] => metrics/cartadditions
)
[8] => Array
(
[id] => metrics/productinstances
)
)
[metricFilters] => Array
(
)
)
[settings] => Array
(
[metricSort] => desc
[limit] => 5000
[page] => 0
[countRepeatInstances] => 1
)
)
when I try to fetch almost the same metrics but on daterange dimension then they are coming fine.
Array
(
[rsid] => XXX
[dimension] => variables/daterangeday
[globalFilters] => Array
(
[0] => Array
(
[type] => dateRange
[dateRange] => 2022-04-01T00:00:00.000/2022-04-02T00:00:00.000
)
)
[metricContainer] => Array
(
[metrics] => Array
(
[0] => Array
(
[id] => metrics/visitors
)
[1] => Array
(
[id] => metrics/bounces
)
[2] => Array
(
[id] => metrics/entries
)
[3] => Array
(
[id] => metrics/carts
)
[4] => Array
(
[id] => metrics/orders
)
[5] => Array
(
[id] => metrics/cartadditions
)
[6] => Array
(
[id] => metrics/productinstances
)
)
[metricFilters] => Array
(
)
)
[settings] => Array
(
[metricSort] => desc
[limit] => 5000
[page] => 0
[countRepeatInstances] => 1
)
)
I am new to Adobe and have very limited access to Adobe experience cloud. What could be the issue.

Related

Working with 2 json arrays with connected data via ID

Been trying to work with two arrays and extract information from the arrays. I can do this with the foreach but I have linked file references (an ID) which targets data in another array.
Array 1 -
Array
(
[type] => land
[id] => 0b1b522e-0cd2-4880-b3ac-a5d86bc2e837
[relationships] => Array
(
[address] => Array
(
[data] => Array
(
[type] => address
[id] => bb89e6c3-9114-4192-a0a7-82c08402d36e
)
)
[details] => Array
(
[data] => Array
(
[type] => details
[id] => f8f0e489-bb86-4857-a815-ab6338d90f26
)
)
[lettingsListing] => Array
(
[data] =>
)
[primaryImage] => Array
(
[data] => Array
(
[type] => media
[id] => 58574088-01a2-45da-a66e-cd3ce1741377
)
)
[images] => Array
(
[data] => Array
(
[0] => Array
(
[type] => media
[id] => 58574088-01a2-45da-a66e-cd3ce1741377
)
[1] => Array
(
[type] => media
[id] => 32d9d605-d55d-48b7-aa62-5e22f762f165
)
[2] => Array
(
[type] => media
[id] => c879656a-a34f-4c93-b6c7-49d3c7b11804
)
[3] => Array
(
[type] => media
[id] => 434f8d79-df19-474d-a275-6c9a5fb0985b
)
[4] => Array
(
[type] => media
[id] => cefccee0-cd30-4c69-9f6f-2bd76116a619
)
[5] => Array
(
[type] => media
[id] => c0377f6c-4279-4176-a5bd-0190b7fd97a8
)
[6] => Array
(
[type] => media
[id] => 6869c65a-bb55-4b9f-8dc1-71ffa5eb84dc
)
[7] => Array
(
[type] => media
[id] => c9b13725-059a-4c96-a8fd-77c9fc9fe05f
)
[8] => Array
(
[type] => media
[id] => edbdddb2-afc7-43ab-9a79-94e0e8e63597
)
[9] => Array
(
[type] => media
[id] => 320de2d7-6ecd-4ec7-9250-f72e228be8a7
)
[10] => Array
(
[type] => media
[id] => 63daaccf-d8d2-4b55-aece-5a01e379fba0
)
[11] => Array
(
[type] => media
[id] => 5d2c253a-03f5-4ea0-b06d-dd17c80d5f3b
)
)
)
)
)
The images in the array are like:
[0] => Array
(
[type] => media
[id] => 58574088-01a2-45da-a66e-cd3ce1741377
)
The ID then corresponds to another array (array 2)
Array
(
[type] => media
[id] => 58574088-01a2-45da-a66e-cd3ce1741377
[attributes] => Array
(
[name] => p048205_01
[order] => 1
[is_featured] =>
[feature_index] =>
[title] =>
[is_image] => 1
[url] => ***urlhere***
)
)
)
So my question is how to get the associated data ([url]) with each ID from the other array. I thought about array_merge but that did not help. My only other thinking is to do a foreach inside the current loop but I have heard it best to not to that?
Create a new array to hold the image urls from what you called array2, but which has the id as the key, so you can jump straight to the URL from your other foreach loop.
$img_urls = []
foreach( $array2 as $a ) {
$img_urls[$a['id']] = $a;
}
Or if you only want the url in this new array
$img_urls = []
foreach( $array2 as $a ) {
$img_urls[$a['id']] = $a['attributes']['url'];
}
As RiggsFolly said, you need to manipulate the second array with images like this:
$new_arr_images = [];
foreach ($arr_images as $value) {
$new_arr_images[$value['id']] = $value['attributes']['url'];
}
// then loop through first array and populate it with image urls based on the ID

How to access the values of this API return

Could you please help me? I need to know how to access the values of this response from an API call using PHP.
Array ( [queryIds] => Array ( [0] => lHLLapn7EH ) [timedOutRealtimeData] => [realtimeDataMissing] => [cacheFreshness] => FRESH [prunedResult] => [novaCost] => 0 [novaRequestDuration] => 19 [wasCached] => 1 [minSampleRate] => 1 [timeComputed] => 1558794556710 [novaRuntime] => 199 [hitChunkGroupByLimit] => [throttleTime] => 0 [data] => Array ( [series] => Array ( [0] => Array ( [0] => Array ( [setId] => [value] => 843 ) ) [1] => Array ( [0] => Array ( [setId] => [value] => 22 ) ) ) [seriesLabels] => Array ( [0] => Array ( [0] => 0 [1] => C5241; GB ) [1] => Array ( [0] => 0 [1] => C9999; GB ) ) [seriesMeta] => Array ( [0] => Array ( [eventGroupBys] => Array ( [0] => C5241 [1] => GB ) [segmentIndex] => 0 [eventIndex] => 0 [eventGroupBy] => C5241; GB ) [1] => Array ( [eventGroupBys] => Array ( [0] => C9999 [1] => GB ) [segmentIndex] => 0 [eventIndex] => 0 [eventGroupBy] => C9999; GB ) ) [seriesCollapsed] => Array ( [0] => Array ( [0] => Array ( [setId] => [value] => 843 ) ) [1] => Array ( [0] => Array ( [setId] => [value] => 22 ) ) ) [xValues] => Array ( [0] => 2019-05-25 ) ) [partialMergedAndNewUserInformation] => [transformationIds] => Array ( [0] => 2696 ) [backend] => novaV2 )
You can access them using
Array ( [0] => C9999 [1] => GB ) -> $arr['data']['seriesMeta'][0]['eventGroupBys']
Array ( [setId] => [value] => 20) -> $arr['data']['seriesMeta'][0][0]

Read complex array from php

I get this array in response from webservice, so How do I read it in a foreach cycle? or some easy way to read it. The [group] they are more than 12 [id]
there is.
Array
( [response] => Array (
[single] => Array ( [parameters] => Array ( [0] => Array ( [name] => msgCode [value] => 0101 )
[1] => Array ( [name] => msgDesc [value] => OK )
[2] => Array ( [name] => status [value] => 1)
[3] => Array ( [name] => message [value] => Normal) ) )
[group] => Array ( [id] => N4BD767 [parameters] => Array ( [0] => Array ( [name] => idFee [value] => 000 ) echo
[1] => Array ( [name] => typeFee [value] => Cuota)
[2] => Array ( [name] => entryDate [value] => 2014-12-17T14:06:47-03:00 )
[3] => Array ( [name] => expirationDate [value] => 2015-12-05T00:00:00-03:00)
[4] => Array ( [name] => amountOrigin [value] => 221980)
[5] => Array ( [name] => surcharges [value] => 1856)
[6] => Array ( [name] => entity [value] => ONLINE)
[7] => Array ( [name] => feeStatus [value] => inicial )
[8] => Array ( [name] => tranNumber [value] => 27) ) ) ) )
Okay guys, this is what I did and it work fine. With no foreach.
$output = array();
array_walk_recursive($result, function($item,$key) use (&$output){
array_push($output,$key,$item);
});
echo var_dump($output);

Unable to extract data from array in php

The array is received from the facebook api and i am not able to extract the likes array from the array,Please help me
[data] => Array (
[0] => Array (
[message] => Hello
[id] => 729659027165160_729651713832558
[likes] => Array (
[data] => Array (
[0] => Array (
[id] => 729659027165160
)
)
[paging] => Array (
[cursors] => Array (
[after] => NzI5NjU5MDI3MTY1MTYw
[before] => NzI5NjU5MDI3MTY1MTYw
)
)
)
)
[1] => Array (
[id] => 729659027165160_718306454967084
[likes] => Array (
[data] => Array (
[0] => Array (
[id] => 1719747118259908
)
)
[paging] => Array (
[cursors] => Array (
[after] => MTcxOTc0NzExODI1OTkwOA==
[before] => MTcxOTc0NzExODI1OTkwOA==
)
)
)
)
[2] => Array (
[id] => 729659027165160_541135166017548
[likes] => Array (
[data] => Array (
[0] => Array (
[id] => 1162428970453842
)
)
[paging] => Array (
[cursors] => Array (
[after] => MTE2MjQyODk3MDQ1Mzg0Mg==
[before] => MTE2MjQyODk3MDQ1Mzg0Mg==
)
)
)
)
[3] => Array (
[message] => Panipaata leni prathivaadu philosophy cheppevade.... Wish Facebook introduce an unlike button soon!!!!
[id] => 729659027165160_520677651396633
[likes] => Array (
[data] => Array (
[0] => Array (
[id] => 1162428970453842
)
[1] => Array (
[id] => 806391372817118
)
[2] => Array (
[id] => 928633297192567
)
[3] => Array (
[id] => 824812004311172
)
[4] => Array (
[id] => 10207344532684729
)
[5] => Array (
[id] => 1188171664544003
)
)
[paging] => Array (
[cursors] => Array (
[after] => MTE4ODE3MTY2NDU0NDAwMw==
[before] => MTE2MjQyODk3MDQ1Mzg0Mg==
)
)
)
)
[4] => Array (
[id] => 729659027165160_110578795739856
[likes] => Array (
[data] => Array (
[0] => Array (
[id] => 1162428970453842
)
)
[paging] => Array (
[cursors] => Array (
[after] => MTE2MjQyODk3MDQ1Mzg0Mg==
[before] => MTE2MjQyO
)
)
)
)
)
I am able to extract the id from the above array,but unable to extract the count of likes and message.
Try this code, it iterates in your array and stores all ids and stores the message, the likes Array and the number of likes only if they exist (Supposing that your array is named $myarray):
$result = array();
foreach($myarray['data'] as $data){
$item = array();
$item['id'] = $data['id'];
if( isset($data['message']) || isset($data['likes']) ){
if(isset($data['message'])) $item['message'] = $data['message'];
if(isset($data['likes'])) {
$item['likes'] = array();
foreach($data['likes']['data'] as $like){
$item['likes'][] = $like['id'];
}
$item['countlikes'] = count( $data['likes']['data'] );
}
}
$result[] = $item;
}
print_r($result);
With your example Array the result will be:
Array
(
[0] => Array
(
[id] => 729659027165160_729651713832558
[message] => Hello
[likes] => Array
(
[0] => 729659027165160
)
[countlikes] => 1
)
[1] => Array
(
[id] => 729659027165160_718306454967084
[likes] => Array
(
[0] => 1719747118259908
)
[countlikes] => 1
)
[2] => Array
(
[id] => 729659027165160_541135166017548
[likes] => Array
(
[0] => 1162428970453842
)
[countlikes] => 1
)
[3] => Array
(
[id] => 729659027165160_520677651396633
[message] => Panipaata leni prathivaadu philosophy cheppevade.... Wish Facebook introduce an unlike button soon!!!!
[likes] => Array
(
[0] => 1162428970453842
[1] => 806391372817118
[2] => 928633297192567
[3] => 824812004311172
[4] => 10207344532684729
[5] => 1188171664544003
)
[countlikes] => 6
)
[4] => Array
(
[id] => 729659027165160_110578795739856
[likes] => Array
(
[0] => 1162428970453842
)
[countlikes] => 1
)
)

Pull out a PHP variable in a complex nested array (from a Drupal View) [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Able to see a variable in print_r()'s output, but not sure how to access it in code
I've got a complex array variable called $data. I need to pull out one very buried value: [url] in [field_website]. Here's the raw print_r() output of the $data variable:
stdClass Object ( [node_title] => CMI2 [nid] => 3 [field_data_field_website_node_entity_type] => node [field_data_field_blog_node_entity_type] => node [field_data_field_rss_node_entity_type] => node [field_data_field_twitter_node_entity_type] => node [field_data_field_yammer_node_entity_type] => node [field_data_field_facebook_node_entity_type] => node [field_data_field_flickr_node_entity_type] => node [field_data_field_youtube_node_entity_type] => node [_field_data] => Array ( [nid] => Array ( [entity_type] => node [entity] => stdClass Object ( [vid] => 3 [uid] => 1 [title] => CMI2 [log] => [status] => 1 [comment] => 1 [promote] => 0 [sticky] => 0 [nid] => 3 [type] => social_source [language] => und [created] => 1356040541 [changed] => 1356040541 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1356040541 [revision_uid] => 1 [field_website] => Array ( [und] => Array ( [0] => Array ( [url] => http://cmi2.yale.edu [title] => [attributes] => Array ( ) ) ) ) [field_blog] => Array ( ) [field_rss] => Array ( ) [field_twitter] => Array ( [und] => Array ( [0] => Array ( [url] => http://twitter.com/yalecmi2 [title] => [attributes] => Array ( ) ) ) ) [field_facebook] => Array ( ) [field_youtube] => Array ( ) [field_flickr] => Array ( ) [field_yammer] => Array ( ) [rdf_mapping] => Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document ) [title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created] => Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array ( [predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) ) [cid] => 0 [last_comment_timestamp] => 1356040541 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => admin [picture] => 0 [data] => b:0; ) ) ) [field_field_website] => Array ( [0] => Array ( [rendered] => Array ( [#markup] => http://cmi2.yale.edu [#access] => 1 ) [raw] => Array ( [url] => http://cmi2.yale.edu [title] => http://cmi2.yale.edu [attributes] => Array ( ) [display_url] => http://cmi2.yale.edu ) ) ) [field_field_blog] => Array ( ) [field_field_rss] => Array ( ) [field_field_twitter] => Array ( [0] => Array ( [rendered] => Array ( [#markup] => http://twitter.com/yalecmi2 [#access] => 1 ) [raw] => Array ( [url] => http://twitter.com/yalecmi2 [title] => http://twitter.com/yalecmi2 [attributes] => Array ( ) [display_url] => http://twitter.com/yalecmi2 ) ) ) [field_field_yammer] => Array ( ) [field_field_facebook] => Array ( ) [field_field_flickr] => Array ( ) [field_field_youtube] => Array ( ) )
(sorry about that ugliness!)
How the heck do I pull out that [url] variable?! Ideally, I just want to assign that one value to another variable or just print it out.
If it's helpful, this is from a Drupal 7 view with the Views PHP module.
Thanks!
I recommend reading up about PHP arrays and objects since what you are trying to do is so trivial.
http://php.net/manual/en/language.types.array.php
http://php.net/manual/en/sdo.sample.getset.php

Categories