shoutoutlabs/shoutout-sdk

3.0.0 2018-04-11 09:18 UTC

This package is not auto-updated.

Last update: 2024-09-26 15:55:21 UTC


README

版本:2.1.0

要求

PHP 5.4.0 及以上版本

安装

您可以通过 composer 安装 shoutout-sdk 或下载源代码

通过 Composer

shoutout-sdkshoutoutlabs/shoutout-sdk 包的形式在 Packagist 上提供

composer require shoutoutlabs/shoutout-sdk

入门

请按照 安装步骤 操作,然后运行以下命令

发送消息

<?php

require __DIR__ . '/vendor/autoload.php';

use Swagger\Client\ShoutoutClient;

$apiKey = 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX';

$client = new ShoutoutClient($apiKey,true,false);


$message = array(
    'source' => 'ShoutDEMO',
    'destinations' => ['94777123456'],
    'content' => array(
        'sms' => 'Sent via SMS Gateway'
    ),
    'transports' => ['SMS']
);

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

?>

创建联系人

<?php

require __DIR__ . '/vendor/autoload.php';

use Swagger\Client\ShoutoutClient;

$apiKey = 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX';

$client = new ShoutoutClient($apiKey,true,false);


$contact = array(
    'mobile_number' => '94777123456',//Required if not specified user_id
    'user_id' => '94777123456',//Optional. if specified, this will be used to generate the contact id, otherwise mobile_number will be used to generate contact id
    //arbitrary attributes
    'email' => 'duke@test.com',
    'tags' => ['lead'],
    'name' => 'Duke'
);
$contacts = array($contact);

try {
    $result = $client->createContacts($contacts);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when creating contacts ', $e->getMessage(), PHP_EOL;
}

?>

创建活动

<?php

require __DIR__ . '/vendor/autoload.php';

use Swagger\Client\ShoutoutClient;

$apiKey = 'XXXXXXXXX.XXXXXXXXX.XXXXXXXXX';

$client = new ShoutoutClient($apiKey,true,false);


$activity = array(
    'userId' => '94777123456',//Required. your account id
    //arbitrary attributes
    'activityName' => 'Sample Activity',
    'activityData' => array(
        'param1' => 'val1',
        'param2' => 'val2',
        'param3' => 'val3'
    )
);

try {
    $result = $client->createActivity($activity);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when creating activity ', $e->getMessage(), PHP_EOL;
}

?>