Add Add new information fr/en

This commit is contained in:
docjyJ 2020-08-22 11:59:33 +02:00
parent 5b37c48d36
commit 72b5fae35f

View file

@ -1,5 +1,6 @@
<?php
require_once 'dao.php';
//require_once '../openfoodfacts-php-0.2.3/src/Api.php';
class PostHandler
{
@ -101,11 +102,24 @@ class PostHandler
public function get_articles_json_list_V3()
{
$api = new OpenFoodFacts\Api('food','fr');
$articles = $this->dao->get_articles();
$formatted_articles = [];
foreach ($articles as $article) {
$product = $api->getProduct('3057640385148');
$article["type"] = $this->dao->get_categories_of_article($article["id"]);
$article["image"] = $this->imageBaseUrl . $article["id"] . ".jpg";
$article["image"] = $product["image_front_url"];
$article["nutri_score"] = $product["nutrition_grade_fr"];
// general $product["ingredients_text"]
$article["ingredients_fr"] = $product["ingredients_text_fr"];
$article["ingredients_en"] = $product["ingredients_text_en"];
// general $product["product_name"]
$article["name_fr"] = $product["product_name_fr"];
$article["name_en"] = $product["product_name_en"];
// general $product["generic_name"]
$article["description_fr"] = $product["generic_name_fr"];
$article["description_en"] = $product["generic_name_en"];
array_push($formatted_articles, $article);
}