PHPackages                             nullform/telegraphus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. nullform/telegraphus

ActiveLibrary[API Development](/categories/api)

nullform/telegraphus
====================

PHP SDK for Telegraph API

v1.1.0(1y ago)07MITPHPPHP ^5.6||^7.0||^8.0

Since Dec 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nullform/telegraphus)[ Packagist](https://packagist.org/packages/nullform/telegraphus)[ Docs](https://github.com/nullform/telegraphus)[ RSS](/packages/nullform-telegraphus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Telegraphus
===========

[](#telegraphus)

The PHP package to interact with [Telegra.ph](https://telegra.ph/).

> Telegra.ph is a minimalist publishing tool that allows you to create richly formatted posts and push them to the Web in just a click.

Requirements
------------

[](#requirements)

- PHP &gt;= 5.6

Installation
------------

[](#installation)

```
composer require nullform/telegraphus
```

Usage examples
--------------

[](#usage-examples)

First you need to create an account and get an access token:

```
use Nullform\Telegraphus\ApiClient;
use Nullform\Telegraphus\Types\Account;

$client = new ApiClient();

$account = new Account();
$account->author_name = 'John Doe';
$account->author_url = 'https://www.google.com/';
$account->short_name = 'john';

try {

    $client->createAccount($account);
    $token = $account->access_token;

    $client->setToken($token);

    // ...

} catch (\Exception $exception) {
    // ...
}
```

Next, you can create pages using the parser to convert your HTML code into *Telegra.ph* format.

```
use Nullform\Telegraphus\ApiClient;
use Nullform\Telegraphus\Parser;

$token = 'token';
$client = new ApiClient($token);
$html = 'Title'
    . 'First paragraph'
    . 'Second paragraph'
    . 'Copyright';

// Note that not all HTML tags are available in Telegra.ph.
// Available tags: a, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4,
// hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video.

$parser = new Parser();

// You can replace or delete tags
$parser->addTagReplaceRules([
    'h1'     => 'h3',  // Convert  to
    'div'    => 'p',   // Convert  to
    'span'   => 'b',   // Convert  to
    'footer' => false, // Remove
]);

try {

    $page = $client->createPage(
        'Test page',
        $parser->htmlToTelegraphContent($html)
    );

    // ...

} catch (\Exception $exception) {
    // ...
}
```

After a successful request, *Telegra.ph* will create a page with the title "Test Page" and the following content:

```
Title
First paragraph
Second paragraph
```

You can pass HTML code as content to the createPage() method. But then the HTML code will be converted to *Telegra.ph* format "as is", without replacing tags.

Don't forget that *Telegra.ph* doesn't support all tags, only the following: a, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4, hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video.

And now you can get a list of all your pages:

```
use Nullform\Telegraphus\ApiClient;

$token = 'token';
$client = new ApiClient($token);

try {

    $pageList = $client->getPageList();

    foreach ($pageList->pages as $page) {
        // ...
    }

} catch (\Exception $exception) {
    // ...
}
```

If you want to edit one:

```
use Nullform\Telegraphus\ApiClient;

$token = 'token';
$client = new ApiClient($token);
$html = 'New page content';
$path = 'page path';

try {

    $page = $client->editPage($path, 'Test page', $html);

    // ...

} catch (\Exception $exception) {
    // ...
}
```

Methods
-------

[](#methods)

### ApiClient

[](#apiclient)

- ApiClient::**\_\_construct**(*?string* $token = null)
- ApiClient::**setToken**(*?string* $token): *ApiClient*
- ApiClient::**getToken**(): *?string*
- ApiClient::**getCurlOptions**(): *array*
- ApiClient::**setCurlOptions**(*array* $curlOptions): *ApiClient*
- ApiClient::**setCurlOption**(*int* $option, *mixed* $value): *ApiClient*
- ApiClient::**getCurlInfo**(): *array*
- ApiClient::**createAccount**(*Account* $account): *Account*
- ApiClient::**editAccountInfo**(*Account* $account): *Account*
- ApiClient::**getAccountInfo**(): *Account*
- ApiClient::**revokeAccessToken**(): *Account*
- ApiClient::**createPage**(*string* $title, *NodeElement\[\]|string* $content, *?string* $authorName = null, *?string* $authorUrl = null): *Page*
- ApiClient::**editPage**(*string* $path, *string* $title, *NodeElement\[\]|string* $content, *?string* $authorName = null, *?string* $authorUrl = null): *Page*
- ApiClient::**getPage**(*string* $path): *Page*
- ApiClient::**getPageList**(*int* $offset = 0, *int* $limit = 50): *PageList*
- ApiClient::**getViews**(*string* $path, *?GetViewsParams* $params): *PageViews*

### Parser

[](#parser)

- Parser::**addTagReplaceRule**(*string* $tag, *string* $toTag): *Parser*
- Parser::**addTagReplaceRules**(*array* $rules): *Parser*
- Parser::**hasTagReplaceRule**(*string* $tag): *bool*
- Parser::**getTagReplaceRule**(*string* $tag): *string|false|null*
- Parser::**setAllowedAttributes**(*?string\[\]* $attributes): *Parser*
- Parser::**setDisallowedAttributes**(*string\[\]* $attributes): *Parser*
- Parser::**htmlToTelegraphContent**(*string* $html): *NodeElement\[\]|string\[\]*
- Parser::**telegraphContentToHtml**(*NodeElement\[\]* $content): *string*
- Parser::**decodeTelegraphContent**(*string* $json): *NodeElement\[\]*

Tests
-----

[](#tests)

Tested on PHP 5.6, 7.2 and 8.0.

```
php composer.phar test tests
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance40

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

2

Last Release

510d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/04a9894c87cf7ea2b58fc41be2ebbb1a999e1906d209e146b0fc2fd9dd9b7b2e?d=identicon)[nullform](/maintainers/nullform)

---

Top Contributors

[![nullform](https://avatars.githubusercontent.com/u/4964609?v=4)](https://github.com/nullform "nullform (3 commits)")

---

Tags

phptelegraphtelegraph-apiphpapiclientparsertelegraph

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nullform-telegraphus/health.svg)

```
[![Health](https://phpackages.com/badges/nullform-telegraphus/health.svg)](https://phpackages.com/packages/nullform-telegraphus)
```

###  Alternatives

[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)[google-gemini-php/symfony

Symfony Bundle for Gemini

149.4k1](/packages/google-gemini-php-symfony)[sima-land/api-php-client

Client library for Simaland APIs

311.5k](/packages/sima-land-api-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
