-
Notifications
You must be signed in to change notification settings - Fork 13
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 #10 from vicent258/clips
Clips
- Loading branch information
Showing
3 changed files
with
97 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,42 @@ | ||
# Users | ||
|
||
Clip objects, top lists. | ||
|
||
[Twitch API](https://github.com/justintv/Twitch-API/blob/master/clips.md) | ||
|
||
## Functions | ||
|
||
`$token` is an optional parameter, but required to be set somewhere. | ||
|
||
```php | ||
<?php | ||
|
||
// Clip object | ||
clip($slug); | ||
|
||
// List of clips in a time period, ordered by views | ||
topClips($options); | ||
|
||
|
||
## Example Usage | ||
|
||
File: `App/Https/Controllers/VideosController.php` | ||
|
||
```php | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use TwitchApi; | ||
use App\Http\Controllers\Controller; | ||
|
||
class ClipsController extends Controller | ||
{ | ||
public function getClip() | ||
{ | ||
// https://clips.twitch.tv/AgreeableOutstandingChickenStinkyCheese | ||
$slug = "AgreeableOutstandingChickenStinkyCheese"; | ||
return TwitchApi::clip($slug); | ||
} | ||
} | ||
``` |
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,36 @@ | ||
<?php | ||
|
||
namespace Zarlach\TwitchApi\API; | ||
|
||
/** | ||
* Twitch documentation: https://github.com/justintv/Twitch-API/blob/master/v3_resources/clips.md. | ||
*/ | ||
class Clips extends Api | ||
{ | ||
/** | ||
* Get clip object. | ||
* | ||
* @param string $slug Clip ID, example: HelloMom | ||
* | ||
* @return JSON Clip object | ||
*/ | ||
public function clip($slug) | ||
{ | ||
return $this->sendRequest('GET', 'clips/'.$slug); | ||
} | ||
|
||
/** | ||
* Get top clips by number of views. | ||
* | ||
* @param array $options Video list options | ||
* | ||
* @return JSON List of videos | ||
*/ | ||
public function clipsTop($options = []) | ||
{ | ||
$availableOptions = ['limit', 'offset', 'game', 'period','limit','trending']; | ||
|
||
return $this->sendRequest('GET', 'clips/top', false, $options, $availableOptions); | ||
} | ||
|
||
} |
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