Get Track detail in gracenote API - gracenote

I am using grace note API to list tracks and albums.
Can anyone please let me know how Can I get track details such as link?
I am getting track_gnid
below is the response to $results = $api->searchTrack("Kings Of Convenience", "Riot On An Empty Street", "Homesick");
[tracks] => Array
(
[0] => Array
(
[track_number] => 1
[track_gnid] => 59247313-E198021B46C38679362C35619E93396B
[track_title] => Homesick
[track_artist_name] => Kings Of Convenience
[mood] => Array
(
)
[tempo] => Array
(
)
)
)
I want to get track link or anything like that

Related

Parsing cybersourse Response in PHP

I Need to parse the below array and retrieve values;status,id.
Below is the PHP Array
Array ( [0] => CyberSource\Model\PtsV2PaymentsPost201Response Object ( [container:protected] =>
Array ( [links] => CyberSource\Model\PtsV2PaymentsPost201ResponseLinks Object ( [container:protected] =>
Array ( [self] => CyberSource\Model\PtsV2PaymentsPost201ResponseLinksSelf
Object ( [container:protected] => Array ( [href] => /pts/v2/payments/621258854395 [method] => GET ) )
[reversal] => [capture] => [customer] => [paymentInstrument] => [shippingAddress] => [instrumentIdentifier] => ) )
[id] => 621258854395
[submitTimeUtc] => 2021-05-17T13:40:55Z
[status] => AUTHORIZED
[reconciliationId] => 621258854395
[errorInformation] =>...............
Below is my php code
$parseApiResponse = new CyberSource\Model\PtsV2PaymentsPost201Response($apiResponse);
print_r("Status"." ".$parseApiResponse->getStatus());
Please assist in resolving this.
Want to do a similar thing as I am able to do in java as below
String status = result.getStatus();
I hope this helps someone. It took me a while to figure this out. The original poster was so close. It's just...
print_r("Status"." ".$apiResponse[0]->getStatus());
No need to instantiate a new "PtsV2PaymentsPost201Response()". The response element ([0]) has already done that when you call, "createPayment()", etc.
lib/Model/PtsV2PaymentsPost201Response.php lists all the available getters. getId(), getStatus(), getLinks(),etc.
$parseApiResponse = new CyberSource\Model\PtsV2PaymentsPost201Response($apiResponse);
$result = \GuzzleHttp\json_decode( $parseApiResponse[0] , true );
return = $result['links'];

How push into array without creating numbered indexes in a multidimensional array in PHP?

I want to use array_push() to add to an array, but it always adds a [0] => Array level. How can I prevent that, or take that out afterwards?
For example, I'm trying to push into the '[addOns] => Array' with this:
$addOnid='gcl1';
$addOnid_arr=array('inheritedFromId' => $addOnid);
array_push($result['addOns'], $addOnid_arr);
The array_push is resulting in this:
Array
(
[addOns] => Array
(
[inheritedFromId] => gcl2
)
[0] => Array
(
[inheritedFromId] => gcl1
)
)
And want to make it:
Array
(
[addOns] => Array
(
[inheritedFromId] => gcl2
)
(
[inheritedFromId] => gcl1
)
)
...basically just getting rid of all the [0] => Array, moving all the subarrays up a level.
Maybe I haven't been using the right queries, but I haven't been able to find out how to do this.
Simple just use this instead:
$addOnid = 'gcl1';
$addOnid_arr['addOns'][] = ['inheritedFromId' => $addOnid];

How are Wordpress Dynamic Sidebar Widgets rendered?

I have been reading through the Wordpress Source, trying to get a better understanding of how dynamic sidebars are rendered.
However, I am hitting a sticking point...
894 | do_action( 'dynamic_sidebar', $wp_registered_widgets[$id] );
I can't find where add_action('dynamic_sidebar', ... ) is defined. Without that part, I am sort of lost in what happens.
See the code here:
https://github.com/WordPress/WordPress/blob/b7c13e27c255e1fc1f03ab2ab432f1652a0ac212/wp-includes/widgets.php#L894
And to give more context, I am trying to figure out how to grab an array of widgets from a specific sidebar, and from there, I need to know how would you render each widget within that array.
I need finer control than dynamic_sidebar(...); gives me
Well, that specific line permits you to access each registered Widget properties, and it's used like:
<?php
/* Plugin Name: Test registered widgets */
add_action( 'dynamic_sidebar', 'sidebar_widgets_so_18666065' );
/**
* As this is an action hook, we don't return nothing
* use the passed values to do your stuff
*/
function sidebar_widgets_so_18666065( $registered_widget )
{
# Each registered widget passes the following array
/*
$registered_widget = Array
(
[name] => Meta
[id] => meta-2
[callback] => Array
(
[0] => WP_Widget_Meta Object
(
[id_base] => meta
[name] => Meta
[widget_options] => Array
(
[classname] => widget_meta
[description] => Log in/out, admin, feed and WordPress links
)
[control_options] => Array
(
[id_base] => meta
)
[number] => 2
[id] => meta-2
[updated] =>
[option_name] => widget_meta
)
[1] => display_callback
)
[params] => Array
(
[0] => Array
(
[number] => 2
)
)
[classname] => widget_meta
[description] => Log in/out, admin, feed and WordPress links
)
*/
}
Relevant search query at WordPress Answers.

Wordpress custom query comparing two timestamp meta data

I am trying to query posts by comparing meta value.
I have set two meta with the posts. i.e. 'start_date' and 'end_date'.
they are stored as UNIX timestamp.
Now I want to query posts on following conditions:
timestamp of current momment is after(greater than) 'start_date'.
timestamp of current momment is before(smaller than) 'end_date'.
In this case, I want both conditions to fulfill. So, I have used 'relation'=>'AND'.
So here is the print_r of the query:
Array
(
[post_type] => ads
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[kye] => start_date
[compare] => <=
[value] => 1352054503
[type] => NUMERIC
)
[1] => Array
(
[kye] => end_date
[compare] => >=
[value] => 1352054503
[type] => NUMERIC
)
)
)
Note: ads is a custom post type.
And here is meta of a post:
Array
(
[start_date] => Array
(
[0] => 1352160000
)
[end_date] => Array
(
[0] => 1352246400
)
)
I see absolutely no reason why this post should show up.
The start date timestamp(1352160000) is bigger than the current timestamp(1352054503). Which breaks condition #1.
So, why is this still showing up?
What do you think?
In your meta_query, you're using "kye" instead of "key".

WP_List_Table not properly handling returned data?

So following the WPEngineer guide on WP_List_Table (excellent guide by the way), I managed to put together a basic table for the backend of a plugin I'm working on. Using an 'example' array, it works great. Problem I'm running into is that I can't figure out for the life of me how to replace that sample data with actual data! Adding the query where I thought it was supposed to be results in the query variable having the correct data, but the table still returns no contents. The referenced pastebin is what I have so far... any thoughts?
http://pastebin.com/f0DCacfF
CORRECTION: It IS pulling the data (if I manually add a row to the database, the table count gets updated), but it's displaying a blank table.
NOTE: It seems that the sample data is an array, whereas $wpdb->get_results is returning as a stdClass Object.
Sample data setup:
var $api_key_list = array(
array( 'id' => 1,'userid' => 'Quarter Share', 'key' => 'Nathan Lowell', 'desc' => '978-0982514542' )
);
Sample data return:
Array ( [0] => Array ( [id] => 1 [userid] => 1 [key] => 098f6bcd4621d373cade4e832627b4f6 [desc] => Test API key ) )
Query setup:
$api_key_list_query = "SELECT * from $wpapi_db_table_name";
$this->api_key_list = $wpdb->get_results($api_key_list_query);
Query return:
Array ( [0] => stdClass Object ( [id] => 1 [userid] => 1 [key] => 098f6bcd4621d373cade4e832627b4f6 [desc] => Test API key ) [1] => stdClass Object ( [id] => 2 [userid] => 1 [key] => 098f6bcd4621d373cade4e832627b4f6 [desc] => Test API key 2 ) )
Adding the following solved my problem.
$this->api_key_list = array();
$i = 0;
foreach($api_key_list_return as $obj) {
foreach($obj as $key => $val) {
$this->api_key_list[$i][$key] = $val;
}
$i++;
}

Resources