Code Monkey home page Code Monkey logo

twitch_interface's Introduction

[UNSTABLE] Twitch Interface V2

Build status

PHP Test Status

[PHP] Twitch Interface

This is a universal PHP interface designed specifically to connect to and interact with the twitch.tv Kraken API servers. It was designed with the intention of being very controlled, safe and light for both the user server and the Kraken API servers. Almost, if not all capable calls are coded directly into the interface, allowing the interface to perform almost, if not all functions that the API allows. Any functions that you believe need to be added or improved can be done via a pull request or opening up an issue.

Currently this interface supports all V5 API calls.

Disclaimer

I am in no way, shape or form associated with, in contract with or partnered with Twitch. This interface is not officially sponsored, endorsed or supported by Twitch. For support on this interface, you may open an issue. Please DO NOT post for help on the developer forums. That is not the place to get library specific help. If you require help in understanding the API, the purpose of endpoints, or help in general with figuring out the workflow for your application, please go to the support forums for those kinds of queries. (No, no one at Twitch asked me to do this...but I saw a few posts asking specifically about my code and that is not the place to get help with the library, here is)

License (TL`DR version)

You can do whatever you want with this piece of software, including modifying it and using it in any way, shape or form. The only requirement is that you keep the credit and the license in the header of the file itself and that you not, in any circumstances redistribute the file in question for the safety of any people who wish to use this software. If you wish to have other people use this software, it is best that you give them the link to this particular git for the latest version of this software and to allow them to find all of the information relating to this piece of software.

For any information about the interface, please look in the module list below.

Advantages

  1. Covers all endpoints for the Kraken V5 API, using a nearly identical structure to Twitch's own documentation.
  2. Smart memory management when making calls
  3. Exception-based error handling for consistent and clean results in production environments
  4. Built-in iterator for making calls over large datasets
  5. Built-in authorization validation

Installation

You may either download the library, or use Composer. Composer is the preferred method of installation for current and dev versions of the library.

Composer

If you do not already have Composer installed, please install composer using the instructions for your platform: (Linux/MacOS | Windows).

Once composer is installed, you can install the following package using whatever your composer implementation demands.

iburn36360/twitch-interface

If you are using composer from the command line, go to your sources directory and run the following command (Replace composer.phar with the real location of your composer PHPArchive and be sure PHP is an environment variable for your system. If you run into errors...these are your issues to google about)

php composer.phar require iburn36360/twitch-interface

Once the package is installed, be sure to include the autoloader from composer into your runtime in your scripts like shown below (Directory location may vary).

<?php

require_once(__DIR__ . '/vendor/autoloader.php');

// Though optional, makes the code cleaner.  I suggest the use statement where it makes sense
use \IBurn36360\TwitchInterface\Modules\Search;
use \IBurn36360\TwitchInterface\Configuration;

$minecraftStreams = Search::streams(new Configuration([
    'clientID' => 'Your Twitch Client ID',
]), [
    'query' => 'minecraft'
])

Documentation/Examples

Module documentation and example usage can be found here

twitch_interface's People

Contributors

iburn36360 avatar lxxrxns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitch_interface's Issues

How to use modules like cURL_get?

Retarded question here. How can I use these private modules like cURL_get, I'm getting 'Call to private method' when doing it directly:
curl_get('https://api.twitch.tv/kraken/streams/dreamhackcs')); ?>
I've read in documentation something about extending the class but didn't quite understand it.

any chance of adding this to composer?

could not find package on packagist.org

would be really helpful if you added it as it seems to be a better package than current alternatives.

please consider it.. thanks much and keep up the fine work!

Some fix

For public function getStreamsObjects()
You need change from:
$streamsObject = $this->get_iterated($functionName, $url, $options, $limit, $offset, 'streams', null, $hls, null, $channels, $embedable, $client_id, null, null, null, $returningTotal);

To:
$streamsObject = $this->get_iterated($functionName, $url, $options, $limit, $offset, 'streams', null, $hls, null, $channels, $embedable, $client_id, null, null, $game, $returningTotal);

Otherwise cURL grab all the game, and not just the chosen one.

generateToken() is always invalid

if(isset($_GET['code'])) {
     $user_code = $_GET['code'];
     $testToken = $interface->generateToken($user_code);
     echo json_encode($testToken);
}

The code is correct, yet it isn't able to get a valid token, ever.

05-21-16||05:25:37 => Generate_Token || Generating auth token
05-21-16||05:25:37 => POST || Starting POST query
05-21-16||05:25:37 => POST || Header row => Accept: application/vnd.twitchtv.v3+json
05-21-16||05:25:37 => POST || Header row => Client-ID: asd (these are correct)
05-21-16||05:25:37 => POST || API Version set to: 3
05-21-16||05:25:37 => POST || No additional options set
05-21-16||05:25:37 => POST || Options set as an array
05-21-16||05:25:37 => POST || command POST => URL: https://api.twitch.tv/kraken/oauth2/token
05-21-16||05:25:37 => POST || POST option: client_id=>asd (these are correct)
05-21-16||05:25:37 => POST || POST option: client_secret=>asd (these are correct)
05-21-16||05:25:37 => POST || POST option: grant_type=>authorization_code
05-21-16||05:25:37 => POST || POST option: redirect_uri=>http://localhost/(not important)/
05-21-16||05:25:37 => POST || POST option: code=>(the code returned by twitch)
05-21-16||05:25:38 => POST || Status Returned: 403
05-21-16||05:25:38 => POST || Cleaning memory
05-21-16||05:25:38 => POST || Returning result
05-21-16||05:25:38 => Generate_Token || Access token not returned
05-21-16||05:25:38 => Generate_Token || Cleaning memory
05-21-16||05:25:38 => Request_Auth || Generating redirect URL
05-21-16||05:25:38 => Request_Auth || Cleaning memory

Above is the logged message when trying to obtain the token.

{
    "token": false,
    "grants": []
}

Iterated calls do not return the first object

Calls for object have the very first object in the set skipped, meaning that if the rows are as follows: {'testUser1': [], ''testUser2'" [], ...} The start of the actual returned data will be with testuser2, not testUser1. Issue in iteration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.