Skip to content

Instantly share code, notes, and snippets.

@KelvinVenancio
Last active August 29, 2015 14:20
Show Gist options
  • Save KelvinVenancio/51a00b0637c7127d8f9b to your computer and use it in GitHub Desktop.
Save KelvinVenancio/51a00b0637c7127d8f9b to your computer and use it in GitHub Desktop.
Consumindo API do Rails com PHP
<?php
$url = "http://localhost:3000/tasks";
$contents = file_get_contents($url);
$contents = utf8_encode($contents);
$results = json_decode($contents, true);
$info = $results;
foreach ($info as $r) {
echo "Nome: $r[name] <br />";
}
?>
/*
Resultado:
Nome: Kelvin
Nome: Bolado
Nome: Vou consumir com PHP
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment