PHP code example of kraken-io / kraken-php
1. Go to this page and download the library: Download kraken-io/kraken-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kraken-io / kraken-php example snippets
en = new Kraken("your-api-key", "your-api-secret");
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"url" => "http://url-to-image.com/file.jpg",
"wait" => true
);
$data = $kraken->url($params);
array(6) {
'success' =>
bool(true)
'file_name' =>
string(8) "file.jpg"
'original_size' =>
int(62422)
'kraked_size' =>
int(52783)
'saved_bytes' =>
int(9639)
'kraked_url' =>
string(65) "http://dl.kraken.io/d1aacd2a2280c2ffc7b4906a09f78f46/file.jpg"
}
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true
);
$data = $kraken->upload($params);
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"lossy" => true
);
$data = $kraken->upload($params);
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"resize" => array(
"width" => 100,
"height" => 75,
"strategy" => "crop"
)
);
$data = $kraken->upload($params);
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"webp" => true,
"lossy" => true
);
$data = $kraken->upload($params);
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"preserve_meta" => array("profile", "geotag")
);
$data = $kraken->upload($params);
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"s3_store" => array(
"key" => "your-amazon-access-key",
"secret" => "your-amazon-secret-key",
"bucket" => "destination-bucket"
)
);
$data = $kraken->upload($params);
"kraked_url" => "http://s3.amazonaws.com/YOUR_CONTAINER/path/to/file.jpg"
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"cf_store" => array(
"user" => "your-rackspace-username",
"key" => "your-rackspace-api-key",
"container" => "destination-container",
"ssl" => true
)
);
$data = $kraken->upload($params);
kraked_url => "http://e9ffc04970a269a54eeb-cc00fdd2d4f11dffd931005c9e8de53a.r2.cf1.rackcdn.com/path/to/file.jpg"
kraked_url => "http://dl.kraken.io/ecdfa5c55d5668b1b5fe9e420554c4ee/file.jpg"
en = new Kraken("your-api-key", "your-api-secret");
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"azure_store" => array(
"account" => "your-azure-account",
"key" => "your-azure-storage-access-key",
"container" => "destination-container"
)
);
$data = $kraken->upload($params);
n = new Kraken("your-api-key", "your-api-secret");
// Minimal request, providing only the mandatory parameters */
$params = array(
"file" => "/path/to/image/file.jpg",
"wait" => true,
"sl_store" => array(
"user" => "your-softlayer-account",
"key" => "your-softlayer-key",
"container" => "destination-container",
"region" => "your-container-location"
)
);
$data = $kraken->upload($params);
n = new Kraken("your-api-key", "your-api-secret");
$params = array(
"url" => "http://awesome-website.com/images/header.jpg",
"wait" => true,
"sl_store" => array(
"user" => "your-softlayer-account",
"key" => "your-softlayer-key",
"container" => "destination-container",
"region" => "your-container-location",
"cdn_url" => true,
"path" => "images/layout/header.jpg"
)
);
$data = $kraken->upload($params);
kraked_url => "http://1c231.http.fra02.cdn.softlayer.net/images/layout/header.jpg"
kraked_url => "http://dl.kraken.io/api/ecdfa5c55d5668b1b5fe9e420554c4ee/header.jpg"