PHP code example of marcortola / food-data-central

1. Go to this page and download the library: Download marcortola/food-data-central library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marcortola / food-data-central example snippets


$foodDataCentralClient = FoodDataCentralClient::create('your_api_key');

// Find food by FDC ID.
$foodItem = $foodDataCentralClient->food()->food(781125);

// Find food nutrients. See the FoodItem interface for more nutrient finders.
$calcium = $foodDataCentralClient->food()->food(781125)->getCalcium();