Scape PHP SDK
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
LICENSE.txt
composer.json
composer.lock
readme.md

readme.md

Scape


Full Documentation   Get API Key   Ideea   Help


PHP SDK for the Scape API

Scape is an Image editing and storage API.

Scape stores images in buckets,

use Ideea\Scape;

Scape::boot('52372b13c197b319cf298511acfe062a8a351141c28975b235f153079d81f8b04');

$res = Scape::upload('/tmp/upload.jpg');

echo $res->url; // "https://cdn.scape.ideea.co.uk/00595909-34d0-4de4-a4fe-402a0c2285ba.jpg"

Links

  • Full Documentation
  • Tutorial
  • Get API Key
  • About

Installation

Require Scape with composer

$ composer require anthonybudd/scape

Setup

To initialize Scape simply call the static method Scape::boot($apiKey), parsing your API key as the first parameter to the function.

Scape::boot('52372b13c197b319cf298511acfe062a8a351141c289335b235f153079d3f8b04');

Overview

createBucket($newBucket)

To create a new bucket to store your images call the static method createBucket($newBucket)

$bucket = Scape::createBucket([
    'name' => 'my-first-bucket'
]);

getBuckets()

The getBuckets() method will return all of your group's buckets.

$buckets = Scape::getBuckets();

foreach($buckets as $bucket){
    echo $bucket->id;       // "00ce6d6a-ea2f-4840-9b5d-cd1f6ae3bc6b"
    echo $bucket->group_id; // 1
    echo $bucket->name;     // "my-first-bucket"
}

getBucket($bucketID)

To get a single bucket call the method getBucket($bucketID).

$bucket = Scape::getBucket('00ce6d6a-ea2f-4840-9b5d-cd1f6ae3bc6b');

echo $bucket->name; // "my-first-bucket"

deleteBucket($bucketID)

To delete a bucket along with all of it's images call deleteBucket($bucketID).

Scape::deleteBucket('00ce6d6a-ea2f-4840-9b5d-cd1f6ae3bc6b');

getImages($bucketID)

To get all images in a bucket

$images = Scape::getImages('00ce6d6a-ea2f-4840-9b5d-cd1f6ae3bc6b');

foreach($images as $image){
    echo $image->id;         // "4fd97b26-39db-4c08-bfb8-2115689dbb8e"
    echo $image->group_id;   // 1
    echo $image->file_size;  // 92900
    echo $image->url;        // "https://cdn.scape.ideea.co.uk/00595909-34d0-4de4-a4fe-402a0c2285ba.jpg:
}

Pagination

To paginate the results of the getImages() method, parse an array with the key 'page' as the second parameter.

$bucketID = '00ce6d6a-ea2f-4840-9b5d-cd1f6ae3bc6b';

$images = Scape::getImages($bucketID, ['page' => 2]);

Upload($filePath)

To upload a file to Scape, call the method upload parsing the file path as the first argument.

$image = Scape::upload('/path/to/my/image.jpg');

echo $image->url; // "https://cdn.scape.ideea.co.uk/00595909-34d0-4de4-a4fe-402a0c2285ba.jpg"

© Ideea x Anthony Budd