This repository has been archived by the owner on May 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from MASNathan/v2.0.0
V2.0.0 - HTTPlug all the way
- Loading branch information
Showing
18 changed files
with
716 additions
and
574 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,3 @@ | ||
/examples export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
vendor/* | ||
*.lock | ||
.idea | ||
|
||
vendor | ||
*.lock |
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
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 |
---|---|---|
@@ -1,24 +1,37 @@ | ||
{ | ||
"name": "masnathan/api-caller", | ||
"type": "library", | ||
"description": "Calling APIs made easy.", | ||
"keywords": ["api","webservice","request","curl"], | ||
"homepage": "https://github.com/ReiDuKuduro/APIcaller", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "André Filipe", | ||
"email": "andre.r.flip@gmail.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"masnathan/curl": "0.0.2" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"MASNathan\\APIcaller\\": "src/" | ||
} | ||
"name": "masnathan/api-caller", | ||
"type": "library", | ||
"description": "Calling APIs made easy.", | ||
"keywords": [ | ||
"api", | ||
"webservice", | ||
"request" | ||
], | ||
"homepage": "https://github.com/MASNathan/APICaller", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "André Filipe", | ||
"email": "andre.r.flip@gmail.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.6", | ||
"php-http/client-implementation": "^1.0", | ||
"php-http/client-common": "^1.2", | ||
"php-http/discovery": "^1.0", | ||
"masnathan/parser": "^0.0.1" | ||
}, | ||
"require-dev": { | ||
"php-http/mock-client": "^1.0.1", | ||
"guzzlehttp/psr7": "^1.0", | ||
"php-http/curl-client": "^1.6", | ||
"symfony/var-dumper": "^3.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MASNathan\\APICaller\\": "src/" | ||
} | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MASNathan\GeoPlugin; | ||
|
||
use MASNathan\APICaller\Caller; | ||
|
||
/** | ||
* GeoPlugin - API Wrapper for http://www.geoplugin.com/, | ||
* Simple example on How to use the APIcaller class to call an API | ||
* | ||
* @author André Filipe <andre.r.flip@gmail.com> | ||
*/ | ||
class GeoPlugin extends Caller | ||
{ | ||
|
||
/** | ||
* Fetches the IP locatio info | ||
* | ||
* @param string $ip | ||
* @param string $baseCurrency i.e.: "EUR" | ||
* @return array | ||
*/ | ||
public function getLocation($ip = '', $baseCurrency = '', $renameArrayKeys = false) | ||
{ | ||
$params = [ | ||
'ip' => !$ip ? $_SERVER['REMOTE_ADDR'] : $ip, | ||
'base_currency' => $baseCurrency, | ||
]; | ||
|
||
$response = $this->client->get('json.gp', $params); | ||
|
||
$data = $this->handleResponseContent($response, 'json'); | ||
|
||
if ($renameArrayKeys) { | ||
$tmpData = []; | ||
foreach ($data as $key => $value) { | ||
$tmpData[str_replace('geoplugin_', '', $key)] = $value; | ||
} | ||
$data = $tmpData; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace MASNathan\GeoPlugin; | ||
|
||
use MASNathan\APICaller\Client; | ||
|
||
/** | ||
* Geoplugin - API Wrapper for http://www.geoplugin.com/, | ||
* Simple example on How to use the APIcaller class to call an API | ||
* | ||
* @author André Filipe <andre.r.flip@gmail.com> | ||
*/ | ||
class GeoPluginClient extends Client | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->setHeaders([ | ||
'Accept' => 'application/json', | ||
]); | ||
} | ||
|
||
public function getEndpoint() | ||
{ | ||
return 'http://www.geoplugin.net/'; | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.