sutho100
2/28/2019 - 12:41 AM

curl API JSON

public function getAdoreMenu($data)   {
        // use curl to download the uri
        $nav_menu_json = 'https://apistage.adorebeauty.com.au/api/nav';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $nav_menu_json);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 3);
        $output = curl_exec($ch);

        if ($output === false) {
            \Log::warning("Failed to retrieve the nav option from Adorebeauty, {$nav_menu_json}, error = " . curl_error($ch));
        }

        curl_close($ch);
        $menu_object = json_decode($output, true);

        $data_arr = array();
        $taxonomy_arr = array();

        return $menu_object;

// dd($menu_object);
//             foreach ($menu_object as $data) {
//             // $data_arr['marketingbanner'] = $data;
//             $data_arr[]['title'] = isset($data['items'][0]['title']) ? $data['items'][0]['title'] : '' ;
//             // $data_arr['shippingbanner'] = $data;
//             // $data_arr['topnav'] = $data;
//             // $data_arr['footernav'] = $data;
//             array_push($data_arr, $taxonomy_arr);

//       }
// dd(($data_arr));

//         return ($data_arr);


      }