Created
April 24, 2019 12:06
-
-
Save nicholas0g/f8025a971ea7068864021656e7dceab3 to your computer and use it in GitHub Desktop.
Trovare carta in base a nome - richiesta get php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//il seguente snippet per fare richiesta get e cercare una carta per nome | |
//funzione che ti fa la chiamata | |
function trovaCarta($nome_carta_da_cercare){ | |
$richiesta = file_get_contents("https://api.scryfall.com/cards/named?fuzzy=".$nome_carta_da_cercare ); | |
//attenzione: non va fatto json_ecnode() perchè già json | |
//attenzione: se va trattata in php come array multidim va fatto json_decode() | |
return $richiesta; | |
} | |
//questo lo uso solo per stampare il rislutato, il set dell'header va tolto se non elabori il json in javascript chiamando questa funzione | |
header('Content-type: text/javascript'); | |
echo trovaCarta("cane+nero"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment