PHP code example of zozocorp / worker

1. Go to this page and download the library: Download zozocorp/worker 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/ */

    

zozocorp / worker example snippets



use Worker\Worker;

// First, instantiate the SDK with your API credentials
$wk = Worker::create('key-example'); // For VI servers

// Now, compose and send your message.
// $wk->messages()->send($domain, $params);
$wk->email()->send('example.com', [
  'from'    => '[email protected]',
  'to'      => '[email protected]',
  'subject' => 'The PHP SDK is awesome!',
  'text'    => 'It is so simple to send a message.'
]);

$wk = Worker::create('key-example');
$dns = $wk->email()->verify(['email' => '[email protected]']);

$wk = Worker::create('key-example');
$dns = $wk->template()->minify(['template' => '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CONVERT HTML TO AMP</title>
</head>
<body>
    <p>MINIFY HTML</p>
</body>
</html>']);

$wk = Worker::create('key-example');
$dns = $wk->template()->amp(['template' => '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CONVERT HTML TO AMP</title>
</head>
<body>
    <p>CONVERT HTML TO AMP</p>
</body>
</html>']);

$wk = Worker::create('key-example');
$dns = $wk->image()->shrink(['image' => $file]);

$wk = Worker::create('key-example');
$dns = $wk->image()->shrink(['image' => $_FILES['image']]);

$wk = Worker::create('key-example');
$dns = $wk->ip()->info(['ip' => '125.212.192.170']);

$width = 1080;
$height = 650;
$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->url()->screenshot(['url' => $url, 'width' => $width, 'height' => $height]);

$width = 1080;
$height = 650;
$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->url()->screenshot(['url' => $url, 'width' => $width, 'height' => $height]);

$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->url()->screenshot(['url' => $url]);

$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->search(
    [
        'index' => 'index name', 
        'keyword' => 'website giáo dục' , 
        'fields' => array('text', 'title', 'description')
    ]);

$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->trendingKeywords(
    [
        'merchant' => 'tên miền doanh nghiệp', 
        'from' => 'thời gian bắt đầu' , 
        'to' => 'thời gian bắt đầu' , 
        'limit' => 'số bản ghi' , 
    ]);

$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->insert(
    ['index' => 'index name' ,
     'data' => array('text' => 'insert content', 'title' => 'insert content', 'description' => 'insert content')
    ]);

$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->get(
    [
        'index' => 'index name', 
        'id' => 1 , 
    ]);

$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->delete(
    [
        'index' => 'index name', 
        'id' => 1 , 
    ]);

$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->createIndex(
    [
        'index' => 'index name', 
    ]);

$url = 'https://zozo.vn/';
$wk = Worker::create('key-example');
$dns = $wk->elasticsearch()->deleteIndex(
    [
        'index' => 'index name', 
    ]);

$type = 'text';
$name = 'zozo'; // Field is optional
$email = '[email protected]'; // Field is optional
$meta = 'zozo.vn - Nền tảng thiết kế Website bán hàng chuyên nghiệp'; // Field is optional
$url = 'https://zozo.vn/'; // Field is optional
$phone = '0960099999'; // Field is optional

$wk = Worker::create('key-example');
$dns = $wk->qrCode()->encode(['type' => $type, 'content' => $meta]);

$type = 'mecard';
$name = 'zozo'; // Field is optional
$email = '[email protected]'; // Field is optional
$address = 'Tầng 7, Toà nhà iNET, số 247 Cầu Giấy, phường Dịch Vọng, Quận Cầu Giấy'; // Field is optional
$url = 'https://zozo.vn/'; // Field is optional
$phone = '0960099999'; // Field is optional

$wk = Worker::create('key-example');
$dns = $wk->qrCode()->encode(['type' => $type, 'name' => $name, 'email' => $email, 'address' => $address, 'url' => $url, 'phone' => $phone]);

$type = 'vcard';
$first_name = 'le'; // Field is optional
$last_name = 'thi'; // Field is optional
$title = 'Nền tảng thiết kế Website bán hàng chuyên nghiệp'; // Field is optional
$company = 'zozo.vn'; // Field is optional
$email = '[email protected]'; // Field is optional
$street = 'Tầng 7, Toà nhà iNET, số 247 Cầu Giấy, phường Dịch Vọng, Quận Cầu Giấy'; // Field is optional
$province = 'Hà Nội'; // Field is optional
$country = 'Việt Nam'; // Field is optional
$url = 'https://zozo.vn/'; // Field is optional
$phone = '0960099999'; // Field is optional

$wk = Worker::create('key-example');
$dns = $wk->qrCode()->encode([
    'first_name' => $first_name, 'last_name' => $last_name, 
    'title' => $title, 'company' => $company, 'email' => $email, 
    'street' => $street, 'province' => $province, 'country' => $country,
    'url' => $url, 'phone' => $phone]);
bash
curl -sS https://getcomposer.org/installer | php