Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit 28bf46b

Browse files
committed
uploaded existing wrapper
1 parent 0599a8a commit 28bf46b

29 files changed

+2369
-2
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
composer.phar
22
/vendor/
3+
phpunit.xml
4+
composer.phar
5+
composer.lock
6+
composer-test.lock
7+
vendor/
38

49
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
510
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Fortnite-API.com
3+
Copyright (c) 2019 Michel
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,149 @@
1-
# php-wrapper
1+
<div align="center">
2+
3+
# PHP wrapper for [Fortnite-API.com](https://fortnite-api.com)
4+
5+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/michel-pi/fortnite-api-php-wrapper)](https://github.com/michel-pi/fortnite-api-php-wrapper/releases) [![Packagist](https://img.shields.io/packagist/dt/michel-pi/fortnite-api)](https://packagist.org/packages/michel-pi/fortnite-api) [![GitHub issues](https://img.shields.io/github/issues/michel-pi/fortnite-api-php-wrapper)](https://github.com/michel-pi/fortnite-api-php-wrapper/issues) [![MIT License](https://img.shields.io/github/license/michel-pi/fortnite-api-php-wrapper)](https://github.com/michel-pi/fortnite-api-php-wrapper/blob/master/LICENSE)
6+
7+
[![Guzzle HTTP](https://img.shields.io/badge/requires-guzzlehttp%2Fguzzle-blue)](https://github.com/guzzle/guzzle) [![PHP version](https://img.shields.io/packagist/php-v/michel-pi/fortnite-api)](https://www.php.net/)
8+
9+
</div>
10+
11+
This library offers a complete wrapper around the endpoints of [fortnite-api.com](https://fortnite-api.com).
12+
13+
All classes and JSON objects are well documented and support autocompletion and type hints for each object and property.
14+
15+
We also have async requests for each endpoint!
16+
17+
## Composer
18+
19+
composer require michel-pi/fortnite-api
20+
21+
## Documentation
22+
23+
Here is a quick overview of the API so you can get started very quickly.
24+
25+
If you need an in-use example then please take a look at the [index.php](https://github.com/michel-pi/fortnite-api-php-wrapper/blob/master/test/index.php) in my test folder where i use some of the endpoints.
26+
27+
- General usage
28+
29+
```php
30+
use MichelPi\FortniteApi\FortniteApi;
31+
32+
require_once __DIR__ . '/../vendor/autoload.php';
33+
34+
$api = new FortniteApi();
35+
```
36+
37+
- FortniteApi class
38+
39+
```php
40+
$api = new FortniteApi();
41+
42+
// accesses the cosmetics endpoint (https://fortnite-api.com/cosmetics)
43+
$api->cosmetics->...
44+
45+
// accesses the news endpoint (https://fortnite-api.com/news)
46+
$api->news->...
47+
48+
// accesses the shop endpoint (https://fortnite-api.com/shop)
49+
$api->shop->...
50+
```
51+
52+
```php
53+
// returns the base uri of the api (https://fortnite-api.com)
54+
FortniteApi::getBaseUri();
55+
56+
// returns an array of all supported languages
57+
FortniteApi::getSupportedLanguages();
58+
```
59+
60+
- FortniteApiError
61+
62+
```php
63+
$result = $api->cosmetics->getAll();
64+
65+
if ($result === null)
66+
{
67+
$lastError = FortniteApiError::getLastError();
68+
69+
// this just shows which members you can access
70+
$members = [
71+
$lastError->statusCode,
72+
$lastError->reasonPhrase,
73+
$lastError->body,
74+
$lastError->message
75+
];
76+
}
77+
```
78+
79+
```php
80+
// Returns the error set by the last request or false if none is set.
81+
FortniteApiError::getLastError();
82+
83+
// Determines whether an error occured within the last called function.
84+
FortniteApiError::hasLastError();
85+
```
86+
87+
- Async methods
88+
89+
Each method in an endpoint has an equivalent async method (i.e. getAsync) which returns an awaitable task. You can await the response at any point in your script.
90+
91+
```php
92+
// returns "instantly"
93+
$task = $api->cosmetics->getAllAsync();
94+
// retreives the result (the one you get from non-async versions)
95+
$result = $task->await();
96+
```
97+
98+
- Endpoints
99+
100+
Each method in one of the endpoints return `null` on failure.
101+
Autocompletion and type hints are provided on each object.
102+
103+
Objects are mapped with the exact same layout as on [fortnite-api.com/documentation](https://fortnite-api.com/documentation) but without their status and data properties which already get validated for you.
104+
105+
If you need more information about properties and methods then please take a look at the actual implementation.
106+
107+
[Endpoints](https://github.com/michel-pi/fortnite-api-php-wrapper/tree/master/src/Components/Endpoints)
108+
109+
[JSON Objects](https://github.com/michel-pi/fortnite-api-php-wrapper/tree/master/src/Components/Objects)
110+
111+
- The `query` parameter
112+
113+
Some methods require a `$query` parameter to work.
114+
You can find possible query parameters within the [official documentation](https://fortnite-api.com/documentation).
115+
An example for such an query `array` would be:
116+
117+
```php
118+
// key value pairs also support arrays as value if the api allows this
119+
$query = [
120+
"rarity" => "uncommon",
121+
"hasIcon" => true
122+
];
123+
```
124+
125+
### Contribute
126+
127+
if you can provide any help, may it only be spell checking please contribute!
128+
129+
I am open for any contribution.
130+
131+
### Donate
132+
133+
Do you like this project or use it commercially?
134+
You can help me continuing my open source projects by using one of the methods to donate (even a single dollar helps and shows that you like my project).
135+
136+
[![Donate via PayPal](https://media.wtf/assets/img/pp.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YJDWMDUSM8KKQ "Donate via PayPal")
137+
138+
```
139+
BTC 14ES7f4GB3vD1C8Faz6ywqTcdDevxZoMyY
140+
141+
ETH 0xd9E2CB12d310E7BF5E72F591D7A2b8820adced04
142+
```
143+
144+
## License
145+
146+
- michel-pi/fortnite-api (MIT) [License](https://github.com/michel-pi/fortnite-api-php-wrapper/blob/master/LICENSE "MIT License")
147+
- guzzlehttp/guzzle (MIT) [License](https://github.com/guzzle/guzzle/blob/master/LICENSE "MIT License")
148+
149+
API developed by [Fortnite-API.com](https://fortnite-api.com/about)

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "michel-pi/fortnite-api",
3+
"description": "PHP wrapper for https://fortnite-api.com",
4+
"keywords": [
5+
"framework",
6+
"wrapper",
7+
"api",
8+
"fortnite",
9+
"fortnite-api",
10+
"client",
11+
"fortnite-api.com",
12+
"michel-pi"
13+
],
14+
"type": "library",
15+
"license": "MIT",
16+
"authors": [
17+
{
18+
"name": "michel-pi",
19+
"email": "[email protected]",
20+
"homepage": "https://github.com/michel-pi/fortnite-api-php-wrapper",
21+
"role": "developer"
22+
}
23+
],
24+
"minimum-stability": "stable",
25+
"require": {
26+
"php": ">=7.0",
27+
"guzzlehttp/guzzle": "^6.4"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"MichelPi\\FortniteApi\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"MichelPi\\FortniteApi\\": "src/"
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)