Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!isset($_GET["submit"])) {
- echo "abrak 3la lbutton al 9lawi ";
- } else {
- if (!isset($_GET["diet"]) || empty($_GET["diet"])) {
- $diet = "";
- } else {
- $diet = $_GET["diet"];
- }
- if (!isset($_GET["number"]) || empty($_GET["number"])) {
- $number = "2";
- } else {
- $number = $_GET["number"];
- }
- if (!isset($_GET["cuisine"]) || empty($_GET["cuisine"])) { // hadi ma5assehach tkoun haka hit l utilisateur 5asse yn3teweh l7a9e ya5tar ktr mn cuisine wa7ed w5asse l sting li yd5al url ykouno mfar9ine fih le cuisine b ,+
- $cuisine = "";
- } else {
- $cuisine = $_GET["cuisine"];
- }
- if (!isset($_GET["maxReadyTime"]) || empty($_GET["maxReadyTime"])) {
- $maxReadyTime = "120";
- } else {
- $maxReadyTime = $_GET["maxReadyTime"];
- }
- $moukawinate = array();
- for ($i = 0; $i < 4; $i++) {
- array_push($moukawinate, $_GET["text" . $i]);
- }
- $result = implode(",", $moukawinate);
- // echo $result;
- // header("Content-Type: application/json");
- // $apiKey = "c407ae4f6f7f4b56b46af81ea67caa2d";
- $apiKey = "871c1b806d07427bbe2d79749900c182";
- $url_Search_Recipes_by_IngredientsPure = "https://api.spoonacular.com/recipes/findByIngredients?apiKey=" . $apiKey . "&ingredients=" . $result . "&number=" . $number . "&ignorePantry=true";
- $data = file_get_contents($url_Search_Recipes_by_IngredientsPure); // put the contents of the file into a variable
- $characters = json_decode($data, false); // decode the JSON feed
- // echo $characters->results[1]->title;
- // header("location:" . $url_Search_Recipes_by_IngredientsPure);
- echo "" . $diet . "<br>";
- $idrecipeAfterFiler = array();
- $indiceRecipescharacters = array();
- $prepa = "preparationMinutes";
- $coking = "cookingMinutes";
- $i = 0;
- foreach ($characters as $recipe) {
- // echo "id :" . $recipe->id . "<br>";
- $urlInformationOfRecipes = "https://api.spoonacular.com/recipes/" . $recipe->id . "/information?apiKey=" . $apiKey . "&includeNutrition=false";
- $dataRecipeI = file_get_contents($urlInformationOfRecipes); // put the contents of the file into a variable
- $ObjectRecipeI = json_decode($dataRecipeI, false);
- if ($ObjectRecipeI->$diet) {
- if ((int) ($ObjectRecipeI->readyInMinutes) <= $maxReadyTime) {
- array_push($idrecipeAfterFiler, $ObjectRecipeI->id);
- array_push($indiceRecipescharacters, $i);
- }
- }
- $i++;
- }
- echo "test finished<br>";
- foreach ($indiceRecipescharacters as $indice) {
- echo "recipes name :" . $characters[$indice]->title;
- }
- // $urlTest = "https://api.spoonacular.com/recipes/" . $characters[0]->id . "/information?apiKey=" . $apiKey . "&includeNutrition=false";
- // header("location:" . $urlTest);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement