PHP code example of pinguo / effectapi-php-sdk

1. Go to this page and download the library: Download pinguo/effectapi-php-sdk 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/ */

    

pinguo / effectapi-php-sdk example snippets


     

use Camera360\Authorization;
use Camera360\EffectManager;

// 用于签名的公钥和私钥
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';

// 1.构造授权类
$authorization = new Authorization($accessKey, $secretKey);
// 2.构造特效处理类
$effectManager = new EffectManager($authorization);
    
// 3.上传图片二进制流
$uploadRet = $effectManager->upload($image);
    
/**
 * 调用上传接口的其他方式
 * 参数 $filter 是滤镜对应的枚举值
 */
// 上传图片二进制流,并自动触发特效处理流程
// $uploadRet = $effectManager->upload($image, $filter);
// 上传图片文件
// $uploadRet = $effectManager->uploadFile($filePath);
// 上传图片文件,并自动触发特效处理流程
// $uploadRet = $effectManager->uploadFile($filePath, $filter);
    
// 4.调用特效处理类的增加特效滤镜接口
$effectPicUrl = $effectManager->addFilter($uploadRet['key'], $filter);
bash
    curl -sS https://getcomposer.org/installer | php
    
bash
    composer