zadarma/user-api-v1 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

zadarma/user-api-v1

最新稳定版本:v1.1.9

Composer 安装命令:

composer require zadarma/user-api-v1

包简介

PHP class for Zadarma API

README 文档

README

An official PHP class for work with Zadarma API.

Allows to work with all API methods (including VoIP, PBX, CallBack etc).

Requirements:

  • PHP >= 5.5.0
  • cURL
  • TLS v1.2

How to use?

An official documentation on Zadarma API is here.

Keys for authorization are in personal account.

Installation

Via Сomposer

composer require "zadarma/user-api-v1"

or just add this line to your composer.json file:

"zadarma/user-api-v1"

Via Git

git clone git@github.com:zadarma/user-api-v1.git

\Zadarma_API\Api call code example

<?php
include_once '/PATH/TO/vendor/autoload.php'; 
$api = new \Zadarma_API\Api(KEY, SECRET, USE_SANDBOX);
try{
    $result = $api->getSipStatus('YOURSIP');
    echo $result->sip.' status: '.($result->is_online ? 'online' : 'offline');
} catch (\Zadarma_API\ApiException $e) {
    echo 'Error: '.$e->getMessage();
}

All other examples you can see in the "example file".

\Zadarma_API\Client call code example

<?php

include_once '/PATH/TO/lib/Client.php';

$params = array(
    'id' => 'YOURSIP',
    'status' => 'on'
);

$zd = new \Zadarma_API\Client(YOUR_KEY, YOUR_SECRET);
/*
$zd->call('METHOD', 'PARAMS_ARRAY', 'REQUEST_TYPE', 'FORMAT', 'IS_AUTH');
where:
- METHOD - a method API, started from /v1/ and ended by '/';
- PARAMS_ARRAY - an array of parameters to a method;
- REQUEST_TYPE: GET (default), POST, PUT, DELETE;
- FORMAT: json (default), xml;
- IS_AUTH: true (default), false - is method under authentication or not.
*/
$answer = $zd->call('/v1/sip/redirection/', $params, 'put');

$answerObject = json_decode($answer);

if ($answerObject->status == 'success') {
    echo 'Redirection on your SIP "' . $answerObject->sip . " has been changed to " . $answerObject->current_status . ".";
} else {
    $answerObject->message;
}

All other examples you can see in the "examples" folder.

统计信息

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

GitHub 信息

  • Stars: 63
  • Watchers: 7
  • Forks: 32
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-24