承接 messagemedia/messages-sdk 相关项目开发

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

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

messagemedia/messages-sdk

Composer 安装命令:

composer require messagemedia/messages-sdk

包简介

The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.

README 文档

README

Important: This SDK is no longer maintained.

This repository (Messages PHP SDK) has not been actively maintained for several years and is now officially deprecated. No further updates, bug fixes, or support will be provided.

If you're building applications that integrate with the Sinch MessageMedia Messaging API, we recommend using direct REST API calls instead. You can find the complete and up-to-date API documentation here:
👉 MessageMedia Messaging REST API Docs

The source code remains available under the Apache 2.0 License. Feel free to fork and update it to suit your needs.

MessageMedia Messages PHP SDK

Pull Requests Welcome HitCount composer

The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.

Isometric

Table of Contents

🔐 Authentication

Authentication is done via API keys. Sign up at https://hub.messagemedia.com/register to get your API keys.

Requests are authenticated using HTTP Basic Auth or HMAC. For Basic Auth, your API key will be basicAuthUserName and API secret will be basicAuthPassword. For HMAC, your API key will be hmacAuthUserName and API secret will be hmacAuthPassword. This is demonstrated in the Send an SMS example below.

⁉️ Errors

Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The most common status codes are listed below.

HTTP Status Codes

Code Title Description
400 Invalid Request The request was invalid
401 Unauthorized Your API credentials are invalid
403 Disabled feature Feature not enabled
404 Not Found The resource does not exist
50X Internal Server Error An error occurred with our API

📰 Information

Mailing List

If you have any questions, comments, or concerns, please email us at: developers@messagemedia.com

Bug reports

If you discover a problem with the SDK, we would like to know about it. You can raise an issue or send an email to: developers@messagemedia.com

Contributing

We welcome your thoughts on how we could best provide you with SDKs that would simplify how you consume our services in your application. You can fork and create pull requests for any features you would like to see or raise an issue. Please be aware that a large share of the files are auto-generated by our backend tool.

⭐ Installation

Run the Composer command to install the latest stable version of the Messages SDK:

composer require messagemedia/messages-sdk

🎬 Get Started

It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below and a mobile number you wish to send to.

Send an SMS

Destination numbers (destinationNumber) should be in the E.164 format. For example, +61491570156 NOT 0491570156. The code snippet below comprises of only the bare minimum parameters required to send a message. You can view the full list of parameters over here. Alternatively, you can refer this code snippet with all the parameters in use.

<?php
require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$messagesController = $client->getMessages();

$body = new Models\SendMessagesRequest;
$body->messages = array();

$body->messages[0] = new Models\Message;
$body->messages[0]->content = 'My first message';
$body->messages[0]->destinationNumber = '+61491570156';

try {
    $result = $messagesController->sendMessages($body);
    print_r($result);
} catch (Exceptions\SendMessages400Response $e) {
    echo 'Caught SendMessages400Response: ',  $e->getMessage(), "\n";
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

Send an MMS

Destination numbers (destinationNumber) should be in the E.164 format. For example, +61491570156 NOT 0491570156. The code snippet below comprises of only the bare minimum parameters required to send a message. You can view the full list of parameters over here. Alternatively, you can refer this code snippet with all the parameters in use.

<?php
require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$messagesController = $client->getMessages();

$body = new Models\SendMessagesRequest;
$body->messages = array();
$body->messages[0] = new Models\Message;
$body->messages[0]->content = 'My second message';
$body->messages[0]->destinationNumber = '+61491570156';
$body->messages[0]->format = Models\FormatEnum::MMS;
$body->messages[0]->media = array('https://images.pexels.com/photos/1018350/pexels-photo-1018350.jpeg?cs=srgb&dl=architecture-buildings-city-1018350.jpg');
$body->messages[0]->subject = 'This is an MMS message';

try {
    $result = $messagesController->sendMessages($body);
    print_r($result);
} catch (Exceptions\SendMessages400Response $e) {
    echo 'Caught SendMessages400Response: ',  $e->getMessage(), "\n";
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

Get Status of a Message

You can get a messsage ID from a sent message by looking at the message_id from the response of the above example.

<?php
require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$messagesController = $client->getMessages();

$messageId = '877c19ef-fa2e-4cec-827a-e1df9b5509f7';

try {
    $result = $messagesController->getMessageStatus($messageId);
    print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

Get replies to a message

You can check for replies that are sent to your messages

<?php
require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$repliesController = $client->getReplies();

try {
    $result = $repliesController->checkReplies();
    print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

Check Delivery Reports

This endpoint allows you to check for delivery reports to inbound and outbound messages.

<?php
require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$deliveryReportsController = $client->getDeliveryReports();

try {
    $result = $deliveryReportsController->checkDeliveryReports();
    print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

Confirm Delivery Reports

This endpoint allows you to mark delivery reports as confirmed so they're no longer returned by the Check Delivery Reports function.

<?php
require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$deliveryReportsController = $client->getDeliveryReports();

$body = new Models\ConfirmDeliveryReportsAsReceivedRequest;
$body->deliveryReportIds = array('011dcead-6988-4ad6-a1c7-6b6c68ea628d', '3487b3fa-6586-4979-a233-2d1b095c7718', 'ba28e94b-c83d-4759-98e7-ff9c7edb87a1');

try {
    $result = $deliveryReportsController->confirmDeliveryReportsAsReceived($body);
    print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

Check credits remaining (Prepaid accounts only)

This endpoint allows you to check for credits remaining on your prepaid account.

<?php

require_once "vendor/autoload.php";

use MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;

$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;

$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);

$messagesController = $client->getMessages();

try {
    $result = $messagesController->checkCreditsRemaining();
    print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n";
}
?>

📕 API Reference Documentation

Check out the full API documentation for more detailed information.

😕 Need help?

Please contact developer support at developers@messagemedia.com or check out the developer portal at developers.messagemedia.com

📃 License

Apache License. See the LICENSE file.

messagemedia/messages-sdk 适用场景与选型建议

messagemedia/messages-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 417.3k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2018 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「sdk」 「messages」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 messagemedia/messages-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 messagemedia/messages-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 messagemedia/messages-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 7
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-02-20