定制 mywhistlebox/mwb-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mywhistlebox/mwb-sdk

最新稳定版本:V1.1.0

Composer 安装命令:

composer require mywhistlebox/mwb-sdk

包简介

A PHP SDK to integrate with the MyWhistleBox platform

README 文档

README

The MyWhistleBox PHP SDK makes it simpler to integrate your PHP applications using the MyWhistleBox REST API. Using the SDK, you will be able to upload files to you box or others, send requests and much more.

Installation

To install the SDK, you will need to be using Composer in your project. If you aren't using Composer yet, it's really simple! Here's how to install composer:

curl -sS https://getcomposer.org/installer | php

Required minimum php version

  • minimum php version 7.4

Steps to install the SDK Package

  • To install the stable release, run the following command in your project directory:

      $ composer require mywhistlebox/mwb-php
    

Getting started

Authentication

To make the API requests, you need to create a MwbClient and provide it with an apikey which can be obtained from your MyWhistleBox Account Settings (API Key tab). Only Enterprise plans will have access to the required keys.

We recommend that you store your credentials in the MWB_AUTH_KEY environment variable, so as to avoid the possibility of accidentally committing them to source control. If you do this, you can initialise the client with no arguments and it will automatically fetch them from the environment variable.

<?php
require 'vendor/autoload.php';
use Mwb\MwbClient;

$client = new MwbClient("<apikey>");

Client Methods

Once you create a client instance, you can use it to call MyWhistleBox methods. The list of methods is described at here.

Method Response

All methods return a json object in the following general format.

Response {
    status: "ok",
    key: object | value,
    ....
}

in addition, if a method results in an error, the response will look like:

Response {
    status: "error",
    code: <error code string>,
    message: <error message string>
}

Simple Ping Test

To make sure you are authenicating properly, we recommend using the Ping method as a test. A simple Ping test may look like so:

<?php
require 'vendor/autoload.php';
use Mwb\MwbClient;

$client = new MwbClient(APIKEY);
$response = $client->ping();
if ($response['status'] == 'ok') {
    echo "RESULT: Server has been pinged successfully<br>\n";
} else {
    if ($response['status'] == 'access') {
        echo "ERROR: Access denied.  Please check your ApiKey<br>\n";
    } else {
        echo "ERROR:". $response['message'];
    }
}

Examples

List Boxes

<?php
require 'vendor/autoload.php';
use Mwb\MwbClient;

$client = new MwbClient(APIKEY);
$response =  $client->listBoxes();
if ($response['status'] == 'ok') {
   print_r($response);
} else {
    if ($response['status'] == 'access') {
        echo "ERROR: Access denied.  Please check your ApiKey<br>\n";
    } else {
        echo "ERROR:". $response['message'];
    }
}

Send an upload request

<?php
require 'vendor/autoload.php';
use Mwb\MwbClient;

$client = new MwbClient(APIKEY);
$response =  $client->requestUpload(<box_id>, <email_address>);
if ($response['status'] == 'ok') {
   print_r($response);
} else {
    if ($response['status'] == 'access') {
        echo "ERROR: Access denied.  Please check your ApiKey<br>\n";
    } else {
        echo "ERROR:". $response['message'];
    }
}

Reporting issues

Report any feedback or problems with this version by opening an issue on Github.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-04