Created
November 18, 2015 17:06
-
-
Save jpetto/eb6cede8df0633feefc9 to your computer and use it in GitHub Desktop.
EWT FA2015 - Yahoo Weather API proxy
This file contains hidden or 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 | |
$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