Error in jason_decode() function

Asked

Viewed 28 times

-1

Well, I’m making a simple page to consume data from a wikipedia api through a short form:

    <form action="" method="get">
    <input type="text" name="busca">
    <input type="submit" value="Busca">
</form>

<?php

    if($_GET['busca']){
        $api_url = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&titles=".ucwords($_GET['busca']).".redirects=true";
        $api_url = str_replace(' ', '%20', $api_url);

        if($data = jason_decode(file_get_contents($api_url))){
            foreach($data->query->pages as $key=>$val){
                $pageId =$key;
                break;
            }
            $conteudo = $data->query->pages->$pageId->extract;

            header('Content-Type:text/html; charset=utf-8');
            echo $content;
        }
        else{
            echo 'Nenhum resultado encontrado.';
        }
    }
?>

php

Fatal error: Uncaught Error: Call to Undefined Function jason_decode()

As we can see below, the json extension is working:

inserir a descrição da imagem aqui

I thought it was because of the IF check, but the error persists.

  • 1

    The correct is json_decode

  • 2

    I suggest paying more attention to the details, the error is clearly Jason and the right thing is json

  • Wow... "Jason"... Personal Obg

  • now I get the following msg: Notice: Undefined Property: stdClass::$Extract in C: xampp htdocs wiki index.php on line 18

1 answer

1


Correct is json_decode() and not jason_decode()

  • Wow... "Jason" was f... Vlw guy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.