Skip to content

Instantly share code, notes, and snippets.

@Michaela-Davis
Created May 11, 2017 21:43
Show Gist options
  • Save Michaela-Davis/fdec6cf3d4de11db31c3ae88e37ac55c to your computer and use it in GitHub Desktop.
Save Michaela-Davis/fdec6cf3d4de11db31c3ae88e37ac55c to your computer and use it in GitHub Desktop.
PHP / Drupal return api results in json format - line 9 - see drupal_cassette-store
class WeatherController
{
public function api() {
$city = 'Missoula';
$state = 'MT';
$weather = 'http://api.wunderground.com/api/28eb4ab328f37f10/conditions/q/' . $state . '/' . $city . '.json';
// $apiKey = '28eb4ab328f37f10';
$result = file_get_contents($weather);
$weather_array = json_decode($result, true);
return new response ($result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment