Browse Source

Add Add new information fr/en

docjyJ 1 year ago
parent
commit
72b5fae35f
1 changed files with 15 additions and 1 deletions
  1. 15
    1
      classes/postHandler.php

+ 15
- 1
classes/postHandler.php View File

@@ -1,5 +1,6 @@
1 1
 <?php
2 2
 require_once 'dao.php';
3
+//require_once '../openfoodfacts-php-0.2.3/src/Api.php';
3 4
 
4 5
 class PostHandler
5 6
 {
@@ -101,11 +102,24 @@ class PostHandler
101 102
 
102 103
     public function get_articles_json_list_V3()
103 104
     {
105
+        $api = new OpenFoodFacts\Api('food','fr');
104 106
         $articles = $this->dao->get_articles();
105 107
         $formatted_articles = [];
106 108
         foreach ($articles as $article) {
109
+            $product = $api->getProduct('3057640385148');
107 110
             $article["type"] = $this->dao->get_categories_of_article($article["id"]);
108
-            $article["image"] = $this->imageBaseUrl . $article["id"] . ".jpg";
111
+            $article["image"] = $product["image_front_url"];
112
+            $article["nutri_score"] = $product["nutrition_grade_fr"];
113
+            // general $product["ingredients_text"]
114
+            $article["ingredients_fr"] = $product["ingredients_text_fr"];
115
+            $article["ingredients_en"] = $product["ingredients_text_en"];
116
+            // general $product["product_name"]
117
+            $article["name_fr"] = $product["product_name_fr"];
118
+            $article["name_en"] = $product["product_name_en"];
119
+            // general $product["generic_name"]
120
+            $article["description_fr"] = $product["generic_name_fr"];
121
+            $article["description_en"] = $product["generic_name_en"];
122
+
109 123
             array_push($formatted_articles, $article);
110 124
         }
111 125
 

Loading…
Cancel
Save