karix/karix-lib

2.0.0 2020-06-29 23:05 UTC

This package is auto-updated.

Last update: 2024-09-29 05:49:31 UTC


README

Build Status Coverage Status

Karix API 允许您使用全渠道消息API与 Karix 平台交互。它还允许您查询您的账户、设置 webhook 和购买电话号码。

此 PHP 包由 Swagger Codegen 项目自动生成

  • API版本:2.0
  • 包版本:2.0.0
  • 构建包:io.swagger.codegen.languages.PhpClientCodegen

需求

PHP 5.6 及以上

安装与使用

Composer

要使用 Composer 安装绑定,请将以下内容添加到 composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/karixtech/karix-php.git"
    }
  ],
  "require": {
    "karixtech/karix-php": "2.0.0"
  }
}

然后运行 composer install

手动安装

下载文件并包含 autoload.php

    require_once('/path/to/karix-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请遵循 安装过程,然后运行以下操作

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP basic authorization: basicAuth
$config = Karix\Configuration::getDefaultConfiguration()
    ->setUsername('ACCOUNT_ID')
    ->setPassword('ACCOUNT_TOKEN');

$apiInstance = new Karix\Api\MessageApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
date_default_timezone_set('UTC');
// Create Message object
$message = (new \Karix\Model\CreateMessage())
    ->setChannel("sms") //Or use "whatsapp"
    ->setSource("+1XXX2321XXX")
    ->setDestination(["+1XXX8323XXX", "+1XXX3234XXX"])
    ->setContent(["text" => "Sent from Karix PHP SDK"]);

try {
    $result = $apiInstance->sendMessage($message);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MessageApi->sendMessage: ', $e->getMessage(), PHP_EOL;
}
?>

API端点文档

所有URI均相对于 https://api.karix.io

模型文档

授权文档

basicAuth

  • 类型:HTTP基本认证

作者

support@karix.io