I have the following JSON from which I need to extract the URL of the icon in PHP:
product
id 3
name "ETC Source 4 19deg"
type "Product"
tax_class_id 2
rental_revenue_group_id 1
sale_revenue_group_id 2
created_at "2017-10-02T10:50:32.239Z"
updated_at "2017-10-02T16:48:44.844Z"
custom_fields {}
product_group {…}
tax_class {…}
icon
id 1
iconable_id 3
iconable_type "Item"
image_file_name "Source_4_fixed.jpg"
url "https://s3.amazonaws.com/current-rms/899701e0-898a-0135-ef0d-0a9ca217e95b/icons/1/original/Source_4_fixed.jpg"
thumb_url "https://s3.amazonaws.com/current-rms/899701e0-898a-0135-ef0d-0a9ca217e95b/icons/1/thumb/Source_4_fixed.jpg"
created_at "2017-10-02T16:48:44.747Z"
updated_at "2017-10-02T16:48:44.747Z"
I have used the following to get the top level info:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
return $data;
public function getProduct( $id )
{
$data = $this->query('products/' . $id);
return $data->product;
}
$html .= '<div class="row">';
$html .= 'Product Name is:' . $product->name;
$html .= '</div>';
echo $html;
Any help appreciated.
Chris