evodelavega/pushover-net 问题修复 & 功能扩展

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

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

evodelavega/pushover-net

Composer 安装命令:

composer require evodelavega/pushover-net

包简介

A simple wrapper for the Pushover.net API

README 文档

README

Simple, standalone, clean PHP wrapper for the pushover.net API

MASTER : Build Status BETA : Build Status PHP5.3 : Build Status

A basic example (push a message):

Pushing a message is quite simple. But unlike other wrappers I've seen, it is equally easy to validate users and groups, Check receipts for pushed message, choose the sounds (through constants) etc...

Here's a simple example:

<?php
$credentials = new Credentials(
    'APP token',
    'user API'
);

//API settings array
$apiSettings = [
    'baseUrl'   => 'the url',//default works fine
    'output'    => Api::OUTPUT_JSON
];

//create message object
$message = new Message(
    [
        'message'  => 'The message',
        'title'    => 'The title',
        'priority' => Message::PRIORITY_EMERGENCY,
        'sound'    => Message::SOUND_GAME
    ],
    $credentials
);

//USING THE WRAPPER:
//get API section:
$api = Api::GetApiSection(
    Api::SECTION_PUSH,//get push section,
    $apiSettings
);

//push message
$response = $api->pushMessage($message);

//check receipt, alternative way of creating API wrapper:
$api = new Receipt($apiSettings);

//get the receipt for the response
$receipt = $api->getReceipt(
    $response,
    $credentials
);

Bascially, this example serves to show that, after constructing the Credentials class, the use of the API is pretty straightforward. After all things have been set up, it's a simple matter of passing through objects.

If anything goes wrong, an appropriate exception will be thrown.

What can this wrapper do?

Good question. Put simply this is a minimalistic setup which allows you to:

  • Push messages (examples/example.php shows you how)
  • Validate users, groups and their devices
  • Process receipts, if you want to
  • Easily extend the functionality (look at the base classes PushOver\Api and PushOver\Model\Data)

What can't it do (yet)?

Another good question. Things that are missing from this wrapper (but will be added shortly) are:

  • Support for XML formatted responses (will not be added any time soon)
  • Unit tests (Are being added now)
  • Improve data-model consistency, and make the overall API more consistent

What might be added in the future?

  • Better error/exception handling
  • Consistency tweaks (return values/property types)
  • Data models should implement the \Traversable interface somehow
  • ...

I'm open to suggestions, so if there's something you're looking for and, like me, found the existing wrappers lacking: create an issue, and I'll be happy to look into it

Getting the example.php script to work

It's as simple as creating the params.json file in the examples directory. The JSON should look something like:

{
    "credentials": {
        "user": "<your user string>",
        "token": "<the API token>"
    },
    "api": {
        "baseUrl": "base url like: https://api.pushover.net/1/",
        "output": ".json (or, when added .xml, xml is currently unsupported)"
    }
}

If you're trying to use the Api::GetApiSection method to load an API class other than PushOver\Push, don't forget to require it (or better yet, register the autoloader composer will helpfully give you)

That's it!

==========

Contributing is optional, but encouraged.

If you see room for improvement, or want to make a suggestion: don't hold back, create issues. Fork, create pull requests... the works. Collaborating is fun.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固