-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
// These two set of lines initiate comprehensive error reporting, so that I can run the routine directly in the browser and see all output, including errors, echoed to the browser screen. To do this, enter the full path of the file as it appears on the web server, file name and extension and then a question mark followed by the parameters, each one separated by an ampersand. | ||
//http://api.geonames.org/countryInfoJSON?formatted=true&lang=it&country=DE&username=shashapi&style=full | ||
ini_set('display_errors', 'On'); | ||
error_reporting(E_ALL); | ||
|
||
// API source url with predefined parameters | ||
$url = "http://api.geonames.org/countryInfoJSON?formatted=true&lang=it&country=DE&username=shashapi&style=full"; | ||
|
||
// Initialize Curl | ||
$ch = curl_init(); | ||
|
||
// FALSE to stop cURL from verifying the peer's certificate. | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
|
||
// TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it directly. | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
|
||
// The URL to fetch. This can also be set when initializing a session with curl_init(). | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
|
||
//Execute the cURL object and stores the result to $result. | ||
$result = curl_exec($ch); | ||
//print_r($result); | ||
|
||
// Finish the session. | ||
curl_close($ch); | ||
|
||
// Convert JSON string into an object. | ||
$decode = json_decode($result, true); | ||
echo json_encode($decode); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
// These two set of lines initiate comprehensive error reporting, so that I can run the routine directly in the browser and see all output, including errors, echoed to the browser screen. To do this, enter the full path of the file as it appears on the web server, file name and extension and then a question mark followed by the parameters, each one separated by an ampersand. | ||
//http://api.geonames.org/weatherJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=shashapi | ||
ini_set('display_errors', 'On'); | ||
error_reporting(E_ALL); | ||
|
||
// API source url with predefined parameters | ||
$url = "http://api.geonames.org/weatherJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=shashapi"; | ||
|
||
// Initialize Curl | ||
$ch = curl_init(); | ||
|
||
// FALSE to stop cURL from verifying the peer's certificate. | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
|
||
// TRUE to return the transfer as a string of the return value of curl_exec//() instead of outputting it directly. | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
|
||
// The URL to fetch. This can also be set when initializing a session with curl_init(). | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
|
||
//Execute the cURL object and stores the result to $result. | ||
$result = curl_exec($ch); | ||
//print_r($result); | ||
|
||
// Finish the session. | ||
curl_close($ch); | ||
|
||
// Convert JSON string into an object. | ||
$decode = json_decode($result, true); | ||
echo json_encode($decode); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
// These two set of lines initiate comprehensive error reporting, so that I can run the routine directly in the browser and see all output, including errors, echoed to the browser screen. To do this, enter the full path of the file as it appears on the web server, file name and extension and then a question mark followed by the parameters, each one separated by an ampersand. | ||
//"http://api.geonames.org/wikipediaSearchJSON?formatted=true&q=london&maxRows=10&username=shashapi&style=full"; | ||
ini_set('display_errors', 'On'); | ||
error_reporting(E_ALL); | ||
|
||
// API source url with predefined parameters | ||
$url = "http://api.geonames.org/wikipediaSearchJSON?formatted=true&q=london&maxRows=10&username=shashapi&style=full"; | ||
|
||
// Initialize Curl | ||
$ch = curl_init(); | ||
|
||
// FALSE to stop cURL from verifying the peer's certificate. | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
|
||
// TRUE to return the transfer as a string of the return value of curl_exec//() instead of outputting it directly. | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
|
||
// The URL to fetch. This can also be set when initializing a session with curl_init(). | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
|
||
//Execute the cURL object and stores the result to $result. | ||
$result = curl_exec($ch); | ||
//print_r($result); | ||
|
||
// Finish the session. | ||
curl_close($ch); | ||
|
||
// Convert JSON string into an object. | ||
$decode = json_decode($result, true); | ||
echo json_encode($decode); |