-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:
I thought it was because of the IF check, but the error persists.
The correct is
json_decode
– Valdeir Psr
I suggest paying more attention to the details, the error is clearly Jason and the right thing is json
– Jader A. Wagner
Wow... "Jason"... Personal Obg
– wes85melis
now I get the following msg: Notice: Undefined Property: stdClass::$Extract in C: xampp htdocs wiki index.php on line 18
– wes85melis