Twitch API Examples

I spend a lot of time on the Twitch Developer forums and Discord helping out other third party developers. That among other things led to me being asked to become a Twitch Ambassador, which is probably a story for another post.

As part of spending a lot of time helping of Forums/Discord, it become useful to write up some examples in various languages for people to refer to, since some people prefer code examples over documentation, and it’s easier to demonstrate how to tie multiple calls/endpoints together for the desired result.

To that end my GitHub Repo at barrycarlyon/twitch_misc now exists and holds examples from Authentication flows (from Implicit to server access and regular user in-between), extension config/pubsub, and examples for Webhooks and the new Eventsub (which is worth a look!). So if you are looking for some examples do checkout the Repository. Some of the examples can even be tested on GitHub itself via GitHub pages, the examples available are listed in the readme and at the Github Pages site.

Twitch also recently made the requirement that all calls to helix (aka the New API) need to be Authenticated using a Bearer, which made it difficult for Extensions to get the viewers details. So to that end I created a basic example of how to do that in an Extension with a “User Profile Extension” example. Which is at BarryCarlyon/twitch_profile_extension. So this covers a good way to handle that flow.

Right now most of the examples are nodeJS, or PHP, but there are some in Python kicking about!

I’ll be looking at adding more examples and other examples in other languages as we go!

I’m usually really bad at commenting my code as I prefer reading the code, but I made a conscious effort to add useful code comments on these repos!

Writing PHP Code to Standard

So with the release of AWS SDK Version 2, I’ve been inspired a little to write better PHP Code, at least in stuff I have on my GitHub. The new SDK is written to match the PHP Framework Interop Group PSR-0, PSR-1 and PSR-2, as well as Composer/Packagist Support.

I been working a on project to make starting a new project easier, (create a repo, setup the deployments, Apache VHost etc). Primarily working off of the ATech Media Suite of products.

Starting from a base of peterjaap’s Codebase PHP Wrapper, where I was just adding missing API endpoints to the class, at which point the new AWS SDK was released and inspiration of a sort struck.

I started a new project from scratch, to implement all the API’s that Atech runs, it’s very much in progress, I’ve currently got full support for DeployHQ and PointHQ end points, (as well as having gotten a few obvious missing end points added to the API).

I’m clunking my way thru the CodeBase API, it’s taking some time as its got a truck load more end points, that DeployHQ and PointHQ put together. It has Projects, which have repos, which have tickets, just to scratch the surface.

At the moment it’s largely functional, it’s just missing some extras, the Time Tracking, File Uploads, and so on.
It’s very much a learning experience in an attempt to follow the coding standards as well as laying the code out properly.

At the moment the CodeBase class itself is pretty large, and I’m pondering about splitting it out to sub classes. Classes to represent Projects and Repos and Tickets and so on, but its the first thing I’ve tried to build in such a way, so much consideration is needed, to hopefully get it right. I keep looking at other Project like the AWS SDK and GoCardless’ PHP Class.

The only thing thats really missing, is Unit Testing, which I still need to sit down and learn properly, but I’m still trying to find a suitable entry point to teach myself, and of late been expanding my knowledge using Code Academy, more on that in another post!

So thats a short update on PHP Development in general, you can checkout the ATech API Class so far on GitHub. Feedback always welcome!

(I’m trying to write more on my blog, as well as more PHP in general, hence a in progress post instead of a “It’s completely finished give it a whirl” post)

Summer

So that middle part of Summer has been a bit sucky. So we shall skip all that, don’t really want to go into it….

Now things are better!

I lost my mac for a week and a half, hard drive failed, followed by back for two hours, followed by hard drive fail.
In the end Clockwork (Leeds Apple Care), replaced the drive and the drive’s cable, and shes all good now!

I’m off to Moor Fest next week, I’m doing the lighting for the Green Room, with Chamsys and whatever fixtures I get given, learnt some useful things from their Chamsys Guide for that matter, (and I fixed up the tab box on the home page for them!) Nice bit of jQuery!

Made a shoutbox for Halo3Wheelmen its hosted on 360gaming.net so had to do a lot of fudging and built a mini phpBB api to get user/ban data out of the forum, its all built in jQuery and PHP, jQuery makes ajax stuff, and append/prepend so much easier than pure javascript.


Job wise I am still waiting to hear back from Firebox.com, but it looks like I shall be staying in Leeds for another year at least, being a Venue Tech, which should, with the new boss, hopefully lead to more external work, but I shall still be working as a freelance web developer. Tho there have been some interesting local jobs come up on the GeekUp jobs Board. (I need to start going to GeekUp again….)

In that vein I currently have a bit of work on building a Asset/Event Manager for LUU Events, details on that to follow, but as a project it keeps me out of trouble, since Google fell thru.

Hopefully I should be getting back into modding phpBB which is even easier now since they now use GitHub to host their repository, so I’m gonna have to get to grips with forks, and loading parent data into the child repo…. (If that makes sense).

So essentially things are busy, not perfect but good. Could be better could be worse…

Hopefully at some point I will get around to doing a Carlyon CMS release candidate, tho I am thinking I need to rip out my CSS boilerplate and thus the relevant core html template files, we shall see.

In other news, I now have completely new graphics for 360gaming [dot] net, I was approached and offered the services of O Sheep Dip, and now I have graphics! Woot!
360gaming.net now has a HogBall league tracker on top of the 1v1 challenger system, tho no one has tested it yet, and I only have the one team, people don’t seem interested…

Tho there is a BTBhub on the way, it was suggested to me that building a BTB league is the way to go, and now I have the core Bungie Code checker, and with the advent of Reach, its data API (POTATO!) and of course, its massive ForgeWorld, the future is bright for Halo and 360gaming.net, now all I need is to find more games with similar developer offerings, and getting myself access to the true Xbox API……

So that summarizes the later part of summer… O and Katie is now home.

Also checkout my tumbleblog

Catch you after Moor Fest, (which will be my first ever festival, I’ve never been to one, and now the first one I am going to is also going to be my first external lighting job….)

Off to watch Sherlock on BBC1

And Happy Birthday to Kayleigh (The GirlFriend) 🙂