PHP code example of pxgamer / spoonacularapi
1. Go to this page and download the library: Download pxgamer/spoonacularapi 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/ */
pxgamer / spoonacularapi example snippets
// Configuration parameters
$xMashapeKey = "xMashapeKey"; // The Mashape application you want to use for this session.
$client = new SpoonacularAPIClient($xMashapeKey);
$client = $client->getClient();
function getProductInformation($id)
$id = 22347;
$result = $client->getProductInformation($id);
function findSimilarRecipes($id)
$id = 156992;
$result = $client->findSimilarRecipes($id);
function getAutocompleteIngredientSearch($query)
$query = 'appl';
$result = $client->getAutocompleteIngredientSearch($query);
function createVisualizePriceBreakdown(
$ingredientList,
$servings,
$defaultCss = 'checked',
$mode = 1,
$fieldParameters = NULL)
$ingredientList = '3 oz flour';
$servings = 2;
$defaultCss = 'checked';
$mode = 1;
// key-value map for optional form parameters
$formParams = array('key' => 'value');
$result = $client->createVisualizePriceBreakdown($ingredientList, $servings, $defaultCss, $mode, $formParams);
function createVisualizeNutrition(
$ingredientList,
$servings,
$defaultCss = 'checked',
$fieldParameters = NULL)
$ingredientList = '3 oz flour';
$servings = 2;
$defaultCss = 'checked';
// key-value map for optional form parameters
$formParams = array('key' => 'value');
$result = $client->createVisualizeNutrition($ingredientList, $servings, $defaultCss, $formParams);
function createVisualizeIngredients(
$ingredientList,
$servings,
$defaultCss = 'checked',
$measure = 'metric',
$view = 'grid',
$fieldParameters = NULL)
$ingredientList = '3 oz flour';
$servings = 2;
$defaultCss = 'checked';
$measure = 'metric';
$view = 'grid';
// key-value map for optional form parameters
$formParams = array('key' => 'value');
$result = $client->createVisualizeIngredients($ingredientList, $servings, $defaultCss, $measure, $view, $formParams);
function getSummarizeRecipe($id)
$id = 4632;
$result = $client->getSummarizeRecipe($id);
function searchGroceryProducts(
$query,
$number = 10,
$offset = 0,
$queryParameters = NULL)
$query = 'snickers';
$number = 10;
$offset = 0;
// key-value map for optional query parameters
$queryParams = array('key' => 'value');
$result = $client->searchGroceryProducts($query, $number, $offset, $queryParams);
function getQuickAnswer($q)
$q = 'How much vitamin c is in 2 apples?';
$result = $client->getQuickAnswer($q);
function getRecipeInformation($id)
$id = 156992;
$result = $client->getRecipeInformation($id);
function createParseIngredients(
$ingredientList,
$servings)
$ingredientList = '3 oz pork shoulder';
$servings = 2;
$result = $client->createParseIngredients($ingredientList, $servings);
function createMapIngredients(
$ingredientList,
$servings)
$ingredientList = '200g flour\\n3 eggs';
$servings = 1;
$result = $client->createMapIngredients($ingredientList, $servings);
function getExtractRecipeFromWebsite(
$url,
$forceExtraction = false,
$queryParameters = NULL)
$url = 'http://www.melskitchencafe.com/the-best-fudgy-brownies/';
$forceExtraction = false;
// key-value map for optional query parameters
$queryParams = array('key' => 'value');
$result = $client->getExtractRecipeFromWebsite($url, $forceExtraction, $queryParams);
function getComputeDailyMealPlan(
$targetCalories,
$timeFrame)
$targetCalories = 2000;
$timeFrame = 'day';
$result = $client->getComputeDailyMealPlan($targetCalories, $timeFrame);
function createClassifyGroceryProductsBatch($productJsonArray)
$productjsonarray = new Productjsonarray();
$productJsonArray = array($productjsonarray);
$result = $client->createClassifyGroceryProductsBatch($productJsonArray);
function createClassifyCuisine(
$ingredientList,
$title)
$ingredientList = '3 oz pork shoulder';
$title = 'Pork roast with green beans';
$result = $client->createClassifyCuisine($ingredientList, $title);
function createClassifyAGroceryProduct($productJson)
$productJson = new Productjson();
$result = $client->createClassifyAGroceryProduct($productJson);
function searchRecipes(
$query,
$cuisine = 'italian',
$diet = 'vegetarian',
$excludeIngredients = 'coconut',
$intolerances = 'egg, gluten',
$limitLicense = false,
$number = 10,
$offset = 0,
$type = 'main course',
$queryParameters = NULL)
$query = 'burger';
$cuisine = 'italian';
$diet = 'vegetarian';
$excludeIngredients = 'coconut';
$intolerances = 'egg, gluten';
$limitLicense = false;
$number = 10;
$offset = 0;
$type = 'main course';
// key-value map for optional query parameters
$queryParams = array('key' => 'value');
$result = $client->searchRecipes($query, $cuisine, $diet, $excludeIngredients, $intolerances, $limitLicense, $number, $offset, $type, $queryParams);
function findByNutrients(
$maxcalories = 1500,
$maxcarbs = 100,
$maxfat = 100,
$maxprotein = 100,
$mincalories = 0,
$minCarbs = 0,
$minfat = 0,
$minProtein = 0,
$queryParameters = NULL)
$maxcalories = 1500;
$maxcarbs = 100;
$maxfat = 100;
$maxprotein = 100;
$mincalories = 0;
$minCarbs = 0;
$minfat = 0;
$minProtein = 0;
// key-value map for optional query parameters
$queryParams = array('key' => 'value');
$result = $client->findByNutrients($maxcalories, $maxcarbs, $maxfat, $maxprotein, $mincalories, $minCarbs, $minfat, $minProtein, $queryParams);
function findByIngredients(
$ingredients,
$limitLicense = false,
$number = 5,
$ranking = 1,
$queryParameters = NULL)
$ingredients = 'apples,flour,sugar';
$limitLicense = false;
$number = 5;
$ranking = 1;
// key-value map for optional query parameters
$queryParams = array('key' => 'value');
$result = $client->findByIngredients($ingredients, $limitLicense, $number, $ranking, $queryParams);
function createRecipeCard(
$backgroundImage,
$image,
$ingredients,
$instructions,
$mask,
$readyInMinutes,
$servings,
$title,
$author = 'Emily Henderson',
$backgroundColor = '#ffffff',
$fontColor = '#333333',
$source = 'spoonacular.com',
$fieldParameters = NULL)
$backgroundImage = 'background1';
$image = The image.;
$ingredients = '2 cups of green beans';
$instructions = 'cook the beans';
$mask = 'ellipseMask';
$readyInMinutes = 60;
$servings = 2;
$title = 'Pork tenderloin with green beans';
$author = 'Emily Henderson';
$backgroundColor = '#ffffff';
$fontColor = '#333333';
$source = 'spoonacular.com';
// key-value map for optional form parameters
$formParams = array('key' => 'value');
$result = $client->createRecipeCard($backgroundImage, $image, $ingredients, $instructions, $mask, $readyInMinutes, $servings, $title, $author, $backgroundColor, $fontColor, $source, $formParams);