承接 serverdox/serverdox-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

serverdox/serverdox-php

最新稳定版本:v1.0

Composer 安装命令:

composer require serverdox/serverdox-php

包简介

The Serverdox SDK provides methods for all API functions.

README 文档

README

This is the Serverdox PHP SDK. This SDK contains methods for easily interacting with the Serverdox API. Below are examples to get you started. For additional examples, please see our official documentation at https://www.serverdox.com/api/docs

Latest Stable Version

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 and the Serverdox SDK.

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

# Add Serverdox as a dependency
php composer.phar require serverdox/serverdox-php:~1.0

For shared hosts without SSH access, check out our Shared Host Instructions.

Rather just download the files? Library Download.

Next, require Composer's autoloader, in your application, to automatically load the Serverdox SDK in your project:

require 'vendor/autoload.php';
use Serverdox\Serverdox;

Usage

Here's how to create a monitor using the SDK:

# First, instantiate the SDK with your API credentials.
$serverdox = new Serverdox("api-key-here");

# Now, create your monitor.
$serverdox->monitors->create(array(
    "name"                      => "Google",
    "url"                       => "https://www.google.com",
    "monitor_server_location"   => "NYC",
    "notes"                     => "My notes about Google.",
    "contacts"                  => array(
        "contact-id-here" => array(
            "sms" => true
        )
    ),
    "me_contact"                => true
));

Or list the 2 most recent monitors created:

# First, instantiate the SDK with your API credentials and define your domain. 
$serverdox = new Serverdox("api-key-here");

# Now, get the monitors.
$serverdox->monitors->all(array(
    'limit' => 2
));

Response

JSON will be returned in all responses from the API, including errors.

Example:

$serverdox = new Serverdox("api-key-here");

$monitors = $serverdox->monitors->all(array(
    'limit' => 2
));

echo '<pre>', print_r($monitors), '</pre>';

Example Contents:
$monitors will contain JSON of the API response. In the above example, something like the following would be displayed:

{
    "monitors": [
        {
            "id": "M_XXXXXXXXXXXXXXXX",
            "name": "Google",
            "url": "https://www.google.com",
            "monitor_server_location": "NYC",
            "current_status": "Pending",
            "notes": "My notes about Google.",
            "run": true,
            "contacts": [
                {
                    "me": false,
                    "C_XXXXXXXXXXXXXXXX": {
                        "email": false,
                        "sms": true,
                        "twitter": false
                    }
                        
                }
            ],
            "created_at": 1420070401
        },
        {
            "id": "M_XXXXXXXXXXXXXXXX",
            "name": "Serverdox",
            "url": "https://www.serverdox.com",
            "monitor_server_location": "LON",
            "current_status": 200,
            "run": true,
            "contacts": [
                {
                    "me": true,
                },
                {
                    "me": false,
                    "C_XXXXXXXXXXXXXXXX": {
                        "email": true,
                        "sms": true,
                        "twitter": false
                    }
                }
            ],
            "created_at": 1420070400
        }
    ],
    "remaining": 3,
    "livemode": true
}

Testing

We aim to make testing our PHP SDK as simple as possible and the only change you need to make is to your API key.

To use the SDK in test mode simply put "test_" before your API key, e.g. "test_XXXXXXXXXXXXXXXX".

In test mode most aspects of the API remain the same including account limits, API limits and errors. However, it is not possible to attach a test contact to a live monitor and vice versa. Trying to retrieve the logs of a monitor in test mode will return an error as this is also not possible in test mode.

Retrieving a test object via the API will have a JSON attribute: "livemode": false.

Support and Feedback

Be sure to visit the Serverdox official API documentation for additional information about our API.

If you find a bug, please submit the issue in Github directly. Serverdox-PHP Issues

As always, if you need additional assistance, contact us at https://serverdox.com/contact.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-15