Utilisation de l'API Premium
L'exemple suivant renvoie le lien d'un message aléatoire.
$opts = array('http' =>
array(
'header' => "Content-Type: text/xml\r\n".
"TOKEN: VOTRE_TOKEN",
)
);
$context = stream_context_create($opts);
$json = file_get_contents("https://api.j0ke.fr/get/message", false, $context);
$obj = json_decode($json);
$image_url= $obj->image_url;
echo $image_url;
# ----- Retour du programme ------ #
# https://api.j0ke.fr/images/message/5207420378a24a21f91c1ddf0f0b4ef3.png
Utilisation de l'API Standard
L'exemple suivant renvoie une devinette aléatoire.
$opts = array('http' =>
array(
'header' => "Content-Type: text/xml\r\n".
"TOKEN: VOTRE_TOKEN",
)
);
$context = stream_context_create($opts);
$json = file_get_contents("https://api.j0ke.fr/get/devinette", false, $context);
$obj = json_decode($json);
$devinette = $obj->devinette;
$reponse = $obj->reponse;
echo $devinette;
echo "<br>";
echo "Réponse : ".$reponse;
# ----- Retour du programme ------ #
# Pourquoi fait-il chaud dans un bus ?
# Réponse : Parce qu'il y a un chauffeur