anton-am/telegraph
Composer 安装命令:
composer require anton-am/telegraph
包简介
Simple telegraph posting library
关键字:
README 文档
README
A simple php library for integration with telegra.ph
Contents
Installation
Raw composer install
composer require anton-am/telegraph
composer.json
"anton-am/telegraph": "^1"
Connecting
//COMPOSER: require_once("vendor/autoload.php");
Usage
Creating new account with random login
$telegraph = new \AntonAm\Telegraph\Manager(); $newAccount = $telegraph->account()->create(); /** AntonAm\Telegraph\Entities\Account Object ( [short_name] => u6127bedb238ee [author_name] => [author_url] => [access_token] => 6dce6d496dbdd6770c28e44b25539d48df0cc08d191f7b499b88ef0872ed [auth_url] => https://edit.telegra.ph/auth/5ckd5ECGzB0KpCpu9I8H0fyJ4f1SrZyw9RJetjT1UR [page_count] => ) */
All available options:
create(YOUR_USER_TOKEN, YOUR_USER_NAME, YOUR_USER_PUBLIC_URL);
Other account methods
$telegraph = new \AntonAm\Telegraph\Manager('ACCESS_TOKEN_FROM_CREATE'); //Get user information $account = $telegraph->account()->get(); //Edit user information $account = $telegraph->account()->edit('NewShortName', 'NewPublicName', 'https://new.url'); //Revoke/reload user access token $account = $telegraph->account()->revoke(); //List of user pages $account = $telegraph->account()->pages();
Creating new page without author
//Create new account and page $telegraph = new \AntonAm\Telegraph\Manager(); $page = $telegraph->page()->setTitle('Sed') ->addText('Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.') ->create();
Edit page
$telegraph = new \AntonAm\Telegraph\Manager('b7316e15f67fe9a397ea8b151d5e15a75a9702e2472775fc3ab0e418467d'); $page = $telegraph->page('Test-08-26-233') ->setAuthor('User Name', 'https://www.google.com/') ->setTitle('Nunc egestas augue') ->addText('Nunc sed turpis. Praesent blandit laoreet nibh. Nam at tortor in tellus interdum sagittis. Quisque id odio. Aliquam lobortis. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam.') ->addLink('Telegraph', 'https://telegra.ph') ->addImage('http://telegra.ph/file/6a5b15e7eb4d7329ca7af.jpg') ->addHtml('hr') ->addHtml('h3', 'Header') ->edit();
All available methods:
setAuthor(); //Autofill of name and url from account (if exist)
setAuthor(USER_NAME, USER_URL);
addText(YOUR_TEXT);
addImage(IMAGE_URL);
addLink(URL_NAME, URL_HREF);
addHtml(TAG, TEXT, ATTRIBUTES)
Other account methods
$telegraph = new \AntonAm\Telegraph\Manager('b7316e15f67fe9a397ea8b151d5e15a75a9702e2472775fc3ab0e418467d'); //Page views statistic $page = $telegraph->page('Test-08-26-233')->statistic(); //Page data $page = $telegraph->page('Test-08-26-233')->get();
All available methods:
statistic(?YEAR, ?MONTH, ?DAY, ?HOUR);
Handling Errors
try { $telegraph = new \AntonAm\Telegraph\Manager(); $newAccount = $telegraph->page()->setTitle('New page')->create('/new'); } catch (\AntonAm\Telegraph\Exceptions\NodeException $e) { //Custom tag problem } catch (\AntonAm\Telegraph\Exceptions\PageException $e) { //Page command problem } catch (\AntonAm\Telegraph\Exceptions\TelegraphRequestException $e){ //Telegraph exception problem } catch (\Exception $e) { //Common problem catcher: guzzle, json decode or something else }
Credits
License
The MIT License (MIT). Please see License File for more information.
anton-am/telegraph 适用场景与选型建议
anton-am/telegraph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 712 次下载、GitHub Stars 达 6, 最近一次更新时间为 2021 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「telegraph」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 anton-am/telegraph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anton-am/telegraph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 anton-am/telegraph 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A laravel facade to interact with Telegram Bots
The simple PHP client for Telegraph API.
The simple PHP client for Telegraph API.
Telegraph API Client for PHP
Simple Telegra.ph API PHP Client
Alfabank REST API integration
统计信息
- 总下载量: 712
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-27