定制 fortytwo/php-sdk-advanced-messaging-platform 二次开发

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

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

fortytwo/php-sdk-advanced-messaging-platform

Composer 安装命令:

composer require fortytwo/php-sdk-advanced-messaging-platform

包简介

Our Advanced Messaging Platform cleverly routes traffic via SMS or IM based on your preferences for delivery and unique knowledge of your audience or it can determine the best way to deliver your message based on factors such as content, cost and deliverability rates.

README 文档

README

This PHP SDK allows you to send messages via SMS or Instant Messages (e.g VIBER) through the Advanced Messaging Platform (AMP) service from Fortytwo Telecom

AMP allows you to send an Instant Message with text, buttons and/or images to end users as well as SMS. The system can be configured in a way that if the end user is not reachable via Instant Messaging, an SMS is sent as a fallback thus ensuring that the end-user is reached.

Create an Account

In order to use the Advanced Messaging Platform, a token is required to autenticate with Fortytwo. This token can be created by [Registering Here] (https://www.fortytwo.com/register/)

Once registered, in the control panel please go to "IM" > "Tokens" and Add a New Token. The token generated above will be used in the code

Setup

Install Composer.

In the root path of your project you have to add the SDK as dependency:

    composer require fortytwo/php-sdk-advanced-messaging-platform
    composer install

Examples:

<?php
/**
 * This Example sends an SMS to a phone number
 * NOTE: If you want to test you have to replace <INSERT_TOKEN_HERE> with a valid token and <PHONE_NUMBER> with a mobile phone number including prefix (e.g 356880000001) .
 */
use Fortytwo\SDK\AdvancedMessagingPlatform\AdvancedMessagingPlatform;
use Fortytwo\SDK\AdvancedMessagingPlatform\Entities\DestinationEntity;
use Fortytwo\SDK\AdvancedMessagingPlatform\Entities\SMSContentEntity;
use Fortytwo\SDK\AdvancedMessagingPlatform\Entities\RequestBodyEntity;

// Using the Composer autoload
require dirname(__FILE__) . '/../vendor/autoload.php';

// Declaring some dependencies for the Serializer
$root = dirname(__FILE__);
Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(
    'JMS\Serializer\Annotation',
    $root . "/../vendor/jms/serializer/src"
);

// To change with a correct token and phone number.
const TOKEN = '<INSERT_TOKEN_HERE>';
const NUMBER = '<PHONE_NUMBER>';

try {
    $messaging = new AdvancedMessagingPlatform(TOKEN);

    //Set destination
    $destination = new DestinationEntity();
    $destination->setNumber(NUMBER);

    //SMS Content
    $SMS = new SMSContentEntity();

    $SMS
        ->setMessage('This is a test SMS message from Fortytwo.')
        ->setSenderId('Fortytwo');

    $request = new RequestBodyEntity();

    $request
        ->addDestination($destination)
        ->setSmsContent($SMS);

    $response = $messaging->sendMessage($request);

    echo $response->getResultInfo()->getDescription() ."\n";

} catch (\Exception $e) {
    echo $e->getMessage();
}

For a full list of examples, go to the examples folder.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固