API presents the main interface to the Publitio RESTful API.
More...
|
static | $VERSION = '2.0.0' |
|
API presents the main interface to the Publitio RESTful API.
You can find more documentation about Publitio at https://publit.io/docs.
◆ __construct()
Publitio\API::__construct |
( |
|
$key, |
|
|
|
$secret |
|
) |
| |
◆ 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_url | The API call endpoint, for example '/files/list'. |
string | $method | The 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 | $args | The URL query parameters. |
- Returns
- object The response JSON parsed using
json_decode
.
- Exceptions
-
BadJSONResponse | when 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 | $file | Pass 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 | $action | Can 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 | $args | The URL query parameters. |
- Returns
- object The response JSON parsed using
json_decode
.
- Exceptions
-
Exception | when $action is invalid. |
BadJSONResponse | when 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_url | The URL of file to upload. |
string | $action | Can 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 | $args | The URL query parameters. |
- Returns
- object The response JSON parsed using
json_decode
.
- Exceptions
-
Exception | when $action is invalid. |
BadJSONResponse | when 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: