I am relatively new to PHP development and would appreciate some help pulling in an array of customers accessed from the Shopify REST API (to a plugin I am writing). This is more about how to handle what is returned than the API itself.
My code is below. I have tried quite a few iterations and this is just the latest failure. My goal is pretty simple, namely retrieve a list of customers.
The REST API call is working i.e. if I copy target_URL into the browser I receive back customers just fine...
which is exactly what I'd expect. So, all seems to be well in terms of the call itself (credentials, endpoint, parameters, etc).
However, the logged entry shows the following (see the code below):
Customers Returned = Array,,
How do I decode this so I can iterate through as an array?
$args = array( 'headers' => array('Content-Type' => 'application/json', 'Accept' => '*/*'), ); $response = wp_remote_get( $target_url , $args ); $customer_array = json_decode( $response['body'], true ); error_log('Customers Returned = ' . $customer_array['customers'] . "," . $customer_array['id'] . "," . $customer_array['email']);