Skip to content

Instantly share code, notes, and snippets.

@jpetto
Created November 18, 2015 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpetto/eb6cede8df0633feefc9 to your computer and use it in GitHub Desktop.
Save jpetto/eb6cede8df0633feefc9 to your computer and use it in GitHub Desktop.
EWT FA2015 - Yahoo Weather API proxy
<?php
$results = array();
$search = (array_key_exists('search', $_REQUEST)) ? $_REQUEST['search'] : '';
if ($search) :
$BASE_URL = "http://query.yahooapis.com/v1/public/yql";
$yql_query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="' . $search . '")';
$yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json";
// Make call with cURL
$session = curl_init($yql_query_url);
curl_setopt($session, CURLOPT_RETURNTRANSFER,true);
$results = curl_exec($session);
endif;
header('Content-Type: application/json; charset=utf8');
echo json_encode($results);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment