Publitio PHP SDK  2.0.0
PHP SDK for Publitio API
Public Member Functions | Static Public Attributes | List of all members
Publitio\API Class Reference

API presents the main interface to the Publitio RESTful API. More...

Public Member Functions

 __construct ($key, $secret)
 
 call ($call_url, $method='GET', $args=array())
 
 uploadFile ($file, $action='file', $args=array())
 
 uploadRemoteFile ($remote_url, $action='file', $args=array())
 

Static Public Attributes

static $VERSION = '2.0.0'
 

Detailed Description

API presents the main interface to the Publitio RESTful API.

You can find more documentation about Publitio at https://publit.io/docs.

Constructor & Destructor Documentation

◆ __construct()

Publitio\API::__construct (   $key,
  $secret 
)
Parameters
string$keyYour API key. You can find your API key on your Publitio dashboard at https://publit.io/dashboard.
string$secretYour API secret. You can find your API secret on your Publitio dashboard at https://publit.io/dashboard.

Member Function Documentation

◆ call()

Publitio\API::call (   $call_url,
  $method = 'GET',
  $args = array() 
)

Make an API call. For a list of avaliable calls, see https://publit.io/docs. Use this method when you aren't going to be uploading any files with the call. If you wish to upload a file, use the uploadFile or uploadRemoteFile methods.

Parameters
string$call_urlThe API call endpoint, for example '/files/list'.
string$methodThe HTTP method, for example 'GET' or 'DELETE'. Which of these you need depends on what kind of call you are making. The method for each API URL is documented at https://publit.io/docs.
array$argsThe URL query parameters.
Returns
object The response JSON parsed using json_decode.
Exceptions
BadJSONResponsewhen the server returns an invalid JSON reponse. Note: if the server is returning an invalid JSON response it is likely that $call_url is invalid, or perhaps there is an internal server error.

◆ uploadFile()

Publitio\API::uploadFile (   $file,
  $action = 'file',
  $args = array() 
)

Upload a file. Use this method when uploading local files from memory. If you wish to upload a file using a remote URL, use uploadRemoteFile.

Parameters
mixed$filePass a string to upload the contents of the string, pass an fopen resource to upload the contents of a PHP stream, or pass a Psr\Http\Message\StreamInterface to upload the contents of a PSR-7 stream.
string$actionCan be 'file' or 'watermark'. If $action is 'file', this method will upload a file to the Publitio server. If $action is 'watermark', this method will upload a watermark to the server. If $action is anything else, an Exception will be thrown.
array$argsThe URL query parameters.
Returns
object The response JSON parsed using json_decode.
Exceptions
Exceptionwhen $action is invalid.
BadJSONResponsewhen the server responds with invalid JSON. This might be due to an internal server error.

◆ uploadRemoteFile()

Publitio\API::uploadRemoteFile (   $remote_url,
  $action = 'file',
  $args = array() 
)

Upload the file at URL $remote_url to the server. If you need to upload a file from memory instead, use uploadFile.

Parameters
string$remote_urlThe URL of file to upload.
string$actionCan be 'file' or 'watermark'. If $action is 'file', this method will upload a file to the Publitio server. If $action is 'watermark', this method will upload a watermark to the server. If $action is anything else, an Exception will be thrown.
array$argsThe URL query parameters.
Returns
object The response JSON parsed using json_decode.
Exceptions
Exceptionwhen $action is invalid.
BadJSONResponsewhen the server responds with invalid JSON. This might be due to an internal server error.

The documentation for this class was generated from the following file: