承接 one2joe/line-notify-sdk-php-no-ssl 相关项目开发

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

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

one2joe/line-notify-sdk-php-no-ssl

Composer 安装命令:

composer require one2joe/line-notify-sdk-php-no-ssl

包简介

LINE Notify SDK for PHP

README 文档

README

LINE Notify SDK for PHP


LINE Notify SDK for PHP

Latest Stable Version License

OUTLINE

DEMONSTRATION

Sample Codes Site for LINE Notify

As a quick start, use Auth client to create an authorize URL with callback redirectUrl for redirection:

$lineNotifyAuth = new \yidas\lineNotify\Auth([
    'clientId' => 'i5zOKhJ9hGyRYdCk281wJr',
    'clientSecret' => '************************',
]);

$authUrl = $$lineNotifyAuth->getAuthUrl("http://localhost/redirectUrl.php");
// header("Location: {$authUrl}");

Next, use Auth client to get accessToken on callback URL (redirectUrl.php), then use Notify client to send notifications with accessToken:

// Get accessToekn by automatically obtaining callback code from query string
$accessToken = $lineNotifyAuth->getAccessToken();

// Send notification with accessToken (Concurrency supported)
$lineNotify = new \yidas\lineNotify\Notify($accessToken);
$result = $lineNotify->notify('Hello!');

REQUIREMENTS

This library requires the following:

Client for LINE Notify

Each LINE Notify service require authentication information for integration, as shown below:

  • Client ID
  • Client Secret

To get a LINE Notify Client:

  1. Register a new LINE Notify service from LINE Notify - Add service with redirectUrl setting.
  2. After registering, get your service's clientId/clientSecret from LINE Notify - Manage registered services (service provider) for integration.

INSTALLATION

Run Composer in your project:

composer require yidas/line-notify-sdk ~1.0.0

Then you could use SDK class after Composer is loaded on your PHP project:

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

use yidas\lineNotify\Auth;
use yidas\lineNotify\Notify;

USAGE

Before using any API methods, first you need to create a Client with configuration, then use the client to access LINE Notify API methods.

Auth Client

Create a LINE Notify Auth Client with API Authentication:

$lineNotifyAuth = new \yidas\lineNotify\Auth([
    'clientId' => 'Your LINE Notify service's client ID',
    'clientSecret' => 'Your LINE Notify service's client Secret',
    // 'debug' => true,
    // 'log' => true,
]);
Parameters
  • array $config:
Key Required Type Default Description
clientId Y string LINE Notify service's client ID
clientSecret Y string LINE Notify service's client Secret
debug N boolean false Debug mode: Throw error exception when API request or result fails
log N boolean false Log mode: Save all responses to each API request

getAuthUrl()

Get LINE Notify OAuth authorize URL

public string getAuthUrl(string $redirectUrl=null, string $state='none', string $responseMode=null)

Example:

// Set redirectUrl to `/callback` from the same path of current URL
define('LINE_NOTIFY_REDIRECT_URL', \yidas\lineNotify\Auth::getWebPath() . "/callback");
$authUrl = $lineNotifyAuth->getAuthUrl(LINE_NOTIFY_REDIRECT_URL);

getAccessToken()

Get AccessToken with redirectUrl and callback's code

public string getAccessToken(string $redirectUri=false, string $code=false, boolean $stateForVerify=false)

Example:

$accessToken = $lineNotifyAuth->getAccessToken(LINE_NOTIFY_REDIRECT_URL, $_GET['code'], 'CSRF state for verifying');

getCode()

Get code on callback redirect URL

static public string getCode(string $stateForVerify=false)

getWebPath()

Get current web URL path

static public string getWebPath()

Notify Client

Create a LINE Notify Client with accessToekn setting:

$lineNotify = new \yidas\lineNotify\Notify('HkyggKbHymoS*****************sFuVfa0mlcBNPI', [
    // 'debug' => true,
    // 'log' => true,
]);
Parameters
  • string|array $accessTokens: Support single or multiple accessTokens for notification
  • array $config:
Key Required Type Default Description
debug N boolean false Debug mode: Throw error exception when API request or result fails
log N boolean false Log mode: Save all responses to each API request

notify()

Send notification concurrently based on accessToken(s)

public integer notify(string $message, array $options=[], string|array $accessTokens=false)

Return Values: Number of successful notifications

Example:

// Send single notification with one accessToken
$lineNotify = new \yidas\lineNotify\Notify('HkyggKbHymoS*****************sFuVfa0mlcBNPI');
$result = $lineNotify->notify('Hello!');

// Send notification for multiple accessTokens concurrently
$lineNotify = new \yidas\lineNotify\Notify(['GymoS****', 'Afa0****']);
$sccessNum = $lineNotify->notify('Hello everyone!');
Options
Option Type Description
message string 1000 characters max
imageThumbnail HTTP/HTTPS URL Maximum size of 240×240px JPEG
imageFullsize HTTP/HTTPS URL Maximum size of 2048×2048px JPEG
imageFile string Local file path
stickerPackageId number Package ID. (Sticker List)
stickerId number Sticker ID.
notificationDisabled boolean Deault is false

Example

$lineNotify = new \yidas\lineNotify\Notify(['HkyggKbHymoS*****************sFuVfa0mlcBNPI']);

// Send notification with image URL options
$successNum = $lineNotify->notify(false, [
    'message' => 'Image Notify',
    'imageThumbnail'=>'https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/LINE_logo.svg/220px-LINE_logo.svg.png',
    'imageFullsize'=>'https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/LINE_logo.svg/440px-LINE_logo.svg.png',
    ]);
    
// Send notification with image upload options
$successNum = $lineNotify->notify(false, [
    'message' => 'Image Notify',
    'imageFile' => '/tmp/filename.png',
    ]);
    
// Send notification with sticker options
$successNum = $lineNotify->notify(false, [
    'message' => 'Sticker Notify',
    'stickerPackageId' => 1,
    'stickerId' => 100,
    ]);

imageFile requires to be a file path of string type

status()

Check accessToken connection status

public array status(string $accessToken)

Example:

$response = $lineNotify->status('HkyggKbHymoS*****************sFuVfa0mlcBNPI');
$statusCode = $response['status'];

revoke()

Revoke accessToken on the connected service side

public  revoke(string $accessToken)

Example:

$result = $lineNotify->revoke('HkyggKbHymoS*****************sFuVfa0mlcBNPI');

setAccessTokens()

Set AccessTokens for sending notification

public self setAccessTokens(array $accessTokens=[])

addAccessToken()

Add an AccessToken for sending notification

public self addAccessToken(string $accessToken)

getRateLimit()

Get last response's Rate Limit information

public array getRateLimit()

Shared Methods

getResponseLogs()

Get response logs when log mode is enabled

public array getResponseLogs()

RESOURCES

LINE Notify (EN)

LINE Notify API Document (EN)

one2joe/line-notify-sdk-php-no-ssl 适用场景与选型建议

one2joe/line-notify-sdk-php-no-ssl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 one2joe/line-notify-sdk-php-no-ssl 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-30