This repository has been archived by the owner on May 10, 2020. 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.
- Loading branch information
0 parents
commit 9010085
Showing
35 changed files
with
3,599 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,8 @@ | ||
# PHPStorm | ||
.idea | ||
|
||
# Composer | ||
vendor/ | ||
|
||
# Others | ||
.php_cs.cache |
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,34 @@ | ||
language: php | ||
|
||
cache: | ||
directories: | ||
- "$HOME/.composer/cache" | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- nightly | ||
- hhvm | ||
|
||
matrix: | ||
allow_failures: | ||
- php: nightly | ||
- php: hhvm | ||
fast_finish: true | ||
|
||
notifications: | ||
on_success: never | ||
on_failure: never | ||
|
||
git: | ||
depth: 1 | ||
|
||
install: | ||
- travis_retry composer install --prefer-dist --no-interaction | ||
|
||
script: | ||
- composer check-code | ||
- composer test |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Jack'lul <https://jacklul.github.io> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,117 @@ | ||
# e621 API | ||
|
||
[![Build Status](https://travis-ci.org/jacklul/e621-api.svg?branch=master)](https://travis-ci.org/jacklul/e621-api) | ||
|
||
Simple PHP API wrapper for e621.net API. | ||
|
||
**This class is currently in development, most of the stuff was not tested and not every method in entities is implemented and documented yet.** | ||
|
||
## Table of Contents | ||
- [Instructions](#instructions) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
|
||
## Instructions | ||
### Installation | ||
|
||
Install this package through [Composer](https://github.com/composer/composer) - `composer require jacklul/e621-api`. | ||
|
||
### Usage | ||
|
||
- Initialize the object with User-Agent "My project": | ||
|
||
```php | ||
require 'vendor/autoload.php'; // don't forget about loading Composer's autloader | ||
|
||
use jacklul\E621API\E621; | ||
|
||
$api = new E621('My project'); | ||
``` | ||
|
||
- Perform request with own parameters: | ||
|
||
```php | ||
$request = $api->postIndex(['tags' => 'falvie cat order:>score', 'limit' => 25]); | ||
``` | ||
|
||
- This will return `Response` object, to get the actual data we make sure the request was successful first before getting result data: | ||
|
||
```php | ||
if ($request->isSuccessful()) { | ||
$results = $request->getResult(); // get the result data | ||
} else { | ||
echo $request->getReason(); // print request failure reason | ||
} | ||
``` | ||
|
||
- In case of `postIndex()` method result will be array of `Post` objects: | ||
|
||
```php | ||
Array | ||
( | ||
[0] => jacklul\E621API\Entity\Post Object | ||
( | ||
[id] => 1194987 | ||
[tags] => 2017 anthro armband bandage cat clothed clothing day digitigrade falvie feathers feline foot_wraps fur hair hi_res male mammal melee_weapon outside scabbard | ||
scarf sheathed_weapon short_hair skimpy sky snow snowing solo standing step_pose sword weapon white_fur white_hair wraps | ||
[locked_tags] => | ||
[description] => | ||
[created_at] => Array | ||
( | ||
[json_class] => Time | ||
[s] => 1492637589 | ||
[n] => 932211000 | ||
) | ||
|
||
[creator_id] => 169756 | ||
[author] => Millcore | ||
[change] => 11649500 | ||
[source] => https://www.furaffinity.net/view/23264446/ | ||
[score] => 49 | ||
[fav_count] => 104 | ||
[md5] => d9988923347357a24ade031b9997de63 | ||
[file_size] => 1776405 | ||
[file_url] => https://static1.e621.net/data/d9/98/d9988923347357a24ade031b9997de63.png | ||
[file_ext] => png | ||
[preview_url] => https://static1.e621.net/data/preview/d9/98/d9988923347357a24ade031b9997de63.jpg | ||
[preview_width] => 96 | ||
[preview_height] => 150 | ||
[sample_url] => https://static1.e621.net/data/sample/d9/98/d9988923347357a24ade031b9997de63.jpg | ||
[sample_width] => 517 | ||
[sample_height] => 800 | ||
[rating] => s | ||
[status] => active | ||
[width] => 776 | ||
[height] => 1200 | ||
[has_comments] => 1 | ||
[has_notes] => | ||
[has_children] => | ||
[children] => | ||
[parent_id] => | ||
[artist] => Array | ||
( | ||
[0] => falvie | ||
) | ||
|
||
[sources] => Array | ||
( | ||
[0] => https://www.furaffinity.net/view/23264446/ | ||
[1] => http://www.furaffinity.net/user/falvie/ | ||
[2] => https://d.facdn.net/art/falvie/1492632100/1492632100.falvie_kodiakonesm.png | ||
) | ||
) | ||
) | ||
``` | ||
|
||
- You can easily iterate over it using `foreach()` and print every image's URL: | ||
|
||
```php | ||
/** @var \jacklul\E621API\Entity\Post $post */ | ||
foreach ($results as $post) { | ||
echo $post->getFileUrl() . PHP_EOL; | ||
} | ||
``` | ||
|
||
## License | ||
|
||
See [LICENSE](LICENSE). |
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 @@ | ||
{ | ||
"name": "jacklul/e621-api", | ||
"type": "library", | ||
"description": "PHP e621 API Wrapper", | ||
"keywords": ["e621", "api", "wrapper"], | ||
"license": "MIT", | ||
"homepage": "https://github.com/jacklul/e621-API", | ||
"support": { | ||
"issues": "https://github.com/jacklul/e621-API/issues", | ||
"source": "https://github.com/jacklul/e621-API" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Jack'lul", | ||
"email": "jacklulcat@gmail.com", | ||
"homepage": "https://jacklul.github.io", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^5.5|^7.0", | ||
"guzzlehttp/guzzle": "^6.3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.0", | ||
"squizlabs/php_codesniffer": "^3.2" | ||
}, | ||
"suggest": { | ||
"ext-curl": "cURL provides better performance and capabilities" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"jacklul\\E621API\\": "src/" | ||
} | ||
}, | ||
"scripts": { | ||
"check-code": [ | ||
"\"vendor/bin/phpcs\" -snp --standard=phpcs.xml.dist --encoding=utf-8 src/ tests/ --report-width=150" | ||
], | ||
"test": [ | ||
"\"vendor/bin/phpunit\"" | ||
] | ||
} | ||
} |
Oops, something went wrong.