chipslays / telegraph
Telegraph API Client for PHP
Installs: 642
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/chipslays/telegraph
Requires (Dev)
- symfony/var-dumper: ^7.3
README
Modern PHP library for Telegraph API. Telegraph is a minimalist anonymous publishing platform created by Telegram. Create beautiful articles in seconds without registration.
Features
- 🚀 Simple & Intuitive API - Fluent interface for easy content building
- 🎨 Rich Content Support - Headers, paragraphs, lists, images, videos, code blocks
- 🔄 HTML Conversion - Automatic HTML to Telegraph format conversion with sanitization
- 🛡️ Type Safe - Full PHP 8.1+ type hints with readonly properties
- 📝 Fully Documented - Comprehensive PHPDoc comments for IDE support
Requirements
- PHP 8.1 or higher
- cURL extension
- JSON extension
Installation
Install via Composer:
composer require chipslays/telegraph
Quick Start
use Telegraph\Telegraph; // Create client $telegraph = new Telegraph; // Create account $account = $telegraph->createAccount( shortName: 'MyBlog', authorName: 'John Doe' ); // IMPORTANT: Save this token! $token = $account->accessToken(); // Create page $page = $account->createPage( title: 'Hello World', content: 'My first Telegraph article!' ); echo "Published: " . $page->url();
$html = <<<HTML <h1>Article Title</h1> <p>Introduction with <strong>bold</strong> text.</p> <img src="https://example.com/image.jpg" /> <p>Regular paragraph with <a href="https://example.com">link</a>.</p> <ul> <li>First item</li> <li>Second item</li> </ul> <blockquote>Important quote</blockquote> HTML; $page = $account->createPageFromHtml('Blog Post', $html);
Usage Examples
You can find code examples in examples folder or in EXAMPLES.md.
License
The MIT License (MIT). Please see License File for more information.