Super-simple, minimum abstraction Transistor API wrapper, in PHP. Format and setup is heavily inspired by DrewM/MailChimp.
Get from the Transistor API docs to the code as directly as possible. Or optionally use the v1 verbose command wrapper as well.
Requires PHP 7.4+.
You will be able to install transistor-api
using Composer, once it's ready.
Alternatively you can just download the Transistor.php
file from the src
folder and include in your project manually:
include( './Transistor.php' );
You can POST
, GET
, DELETE
, and PATCH
using this API, depending on the permissions your user has within Transistor.
Begin by use
-ing the class and creating an instance with your API key:
use \CreateWithRani\Transistor\Transistor;
$transistor = new Transistor('lD8123432345434543');
You can see your own user details with a wrapper-specific call:
$user_details = $transistor->user();
print_r( $user_details );
Then you can list all the shows you have access to:
$shows = $transistor->get( 'shows' );
print_r( $shows );
Get the details of a specific show by ID:
$show = $transistor->get( 'shows/id' );
print_r( $show );
Get a list of the episodes in your show:
$episodes = $transistor->get( 'episodes', array(
'show_id' => show_id
) );
print_r( $episodes );
To get the last error returned by either the HTTP client or by the API, use get_last_error()
:
echo $transistor->get_last_error();
For further debugging, you can inspect the headers and body of the response:
print_r( $transistor->get_last_response() );
If you suspect you're sending data in the wrong format, you can look at what was sent to Transistor by the wrapper:
print_r( $transistor->get_last_request() );
This is a pretty simple wrapper with an optionally more verbose commands class if you want/need something easier than going straight to the API.
Feel free to suggest an improvement by creating an issue.
Pull requests for bugs are more than welcome - please explain the bug you're trying to fix in the message.