{"id":33988337,"url":"https://github.com/nullform/telegraphus","last_synced_at":"2025-12-13T05:55:59.514Z","repository":{"id":268609284,"uuid":"904910322","full_name":"nullform/telegraphus","owner":"nullform","description":"PHP SDK for Telegraph API","archived":false,"fork":false,"pushed_at":"2024-12-24T16:50:28.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-16T18:43:45.740Z","etag":null,"topics":["php","telegraph","telegraph-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nullform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-17T19:35:04.000Z","updated_at":"2024-12-24T16:50:32.000Z","dependencies_parsed_at":"2024-12-17T20:51:25.627Z","dependency_job_id":null,"html_url":"https://github.com/nullform/telegraphus","commit_stats":null,"previous_names":["nullform/telegraphus"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nullform/telegraphus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullform%2Ftelegraphus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullform%2Ftelegraphus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullform%2Ftelegraphus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullform%2Ftelegraphus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nullform","download_url":"https://codeload.github.com/nullform/telegraphus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullform%2Ftelegraphus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27701217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","telegraph","telegraph-api"],"created_at":"2025-12-13T05:55:58.757Z","updated_at":"2025-12-13T05:55:59.506Z","avatar_url":"https://github.com/nullform.png","language":"PHP","readme":"# Telegraphus\n\nThe PHP package to interact with [Telegra.ph](https://telegra.ph/).\n\n\u003e Telegra.ph is a minimalist publishing tool that allows you to create richly formatted posts\n\u003e and push them to the Web in just a click.\n\n## Requirements\n\n- PHP \u003e= 5.6\n\n## Installation\n\n```shell\ncomposer require nullform/telegraphus\n```\n\n## Usage examples\n\nFirst you need to create an account and get an access token:\n\n```php\nuse Nullform\\Telegraphus\\ApiClient;\nuse Nullform\\Telegraphus\\Types\\Account;\n\n$client = new ApiClient();\n\n$account = new Account();\n$account-\u003eauthor_name = 'John Doe';\n$account-\u003eauthor_url = 'https://www.google.com/';\n$account-\u003eshort_name = 'john';\n\ntry {\n\n    $client-\u003ecreateAccount($account);\n    $token = $account-\u003eaccess_token;\n\n    $client-\u003esetToken($token);\n\n    // ...\n\n} catch (\\Exception $exception) {\n    // ...\n}\n```\n\nNext, you can create pages using the parser to convert your HTML code into *Telegra.ph* format.\n\n```php\nuse Nullform\\Telegraphus\\ApiClient;\nuse Nullform\\Telegraphus\\Parser;\n\n$token = 'token';\n$client = new ApiClient($token);\n$html = '\u003ch1\u003eTitle\u003c/h1\u003e'\n    . '\u003cdiv\u003eFirst paragraph\u003c/div\u003e'\n    . '\u003cdiv\u003eSecond \u003cspan\u003eparagraph\u003c/span\u003e\u003c/div\u003e'\n    . '\u003cfooter\u003eCopyright\u003c/footer\u003e';\n\n// Note that not all HTML tags are available in Telegra.ph.\n// Available tags: a, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4,\n// hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video.\n\n$parser = new Parser();\n\n// You can replace or delete tags\n$parser-\u003eaddTagReplaceRules([\n    'h1'     =\u003e 'h3',  // Convert \u003ch1\u003e to \u003ch3\u003e\n    'div'    =\u003e 'p',   // Convert \u003cdiv\u003e to \u003cp\u003e\n    'span'   =\u003e 'b',   // Convert \u003cspan\u003e to \u003cb\u003e\n    'footer' =\u003e false, // Remove \u003cfooter\u003e\n]);\n\ntry {\n\n    $page = $client-\u003ecreatePage(\n        'Test page',\n        $parser-\u003ehtmlToTelegraphContent($html)\n    );\n\n    // ...\n\n} catch (\\Exception $exception) {\n    // ...\n}\n```\n\nAfter a successful request, *Telegra.ph* will create a page with the title \"Test Page\" and the following content:\n\n```html\n\u003ch3\u003eTitle\u003c/h3\u003e\n\u003cp\u003eFirst paragraph\u003c/p\u003e\n\u003cp\u003eSecond \u003cb\u003eparagraph\u003c/b\u003e\u003c/p\u003e\n```\n\nYou can pass HTML code as content to the createPage() method.\nBut then the HTML code will be converted to *Telegra.ph* format \"as is\", without replacing tags.\n\nDon't forget that *Telegra.ph* doesn't support all tags, only the following:\na, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4, hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video.\n\nAnd now you can get a list of all your pages:\n\n```php\nuse Nullform\\Telegraphus\\ApiClient;\n\n$token = 'token';\n$client = new ApiClient($token);\n\ntry {\n\n    $pageList = $client-\u003egetPageList();\n\n    foreach ($pageList-\u003epages as $page) {\n        // ...\n    }\n\n} catch (\\Exception $exception) {\n    // ...\n}\n```\n\nIf you want to edit one:\n\n```php\nuse Nullform\\Telegraphus\\ApiClient;\n\n$token = 'token';\n$client = new ApiClient($token);\n$html = '\u003cp\u003eNew page content\u003c/p\u003e';\n$path = 'page path';\n\ntry {\n\n    $page = $client-\u003eeditPage($path, 'Test page', $html);\n\n    // ...\n\n} catch (\\Exception $exception) {\n    // ...\n}\n```\n\n## Methods\n\n### ApiClient\n\n- ApiClient::**__construct**(*?string* $token = null)\n- ApiClient::**setToken**(*?string* $token): *ApiClient*\n- ApiClient::**getToken**(): *?string*\n- ApiClient::**getCurlOptions**(): *array*\n- ApiClient::**setCurlOptions**(*array* $curlOptions): *ApiClient*\n- ApiClient::**setCurlOption**(*int* $option, *mixed* \\$value): *ApiClient*\n- ApiClient::**getCurlInfo**(): *array*\n- ApiClient::**createAccount**(*Account* $account): *Account*\n- ApiClient::**editAccountInfo**(*Account* $account): *Account*\n- ApiClient::**getAccountInfo**(): *Account*\n- ApiClient::**revokeAccessToken**(): *Account*\n- ApiClient::**createPage**(*string* \\$title, *NodeElement[]|string* \\$content, *?string* \\$authorName = null, *?string* \\$authorUrl = null): *Page*\n- ApiClient::**editPage**(*string* \\$path, *string* \\$title, *NodeElement[]|string* \\$content, *?string* \\$authorName = null, *?string* \\$authorUrl = null): *Page*\n- ApiClient::**getPage**(*string* $path): *Page*\n- ApiClient::**getPageList**(*int* \\$offset = 0, *int* \\$limit = 50): *PageList*\n- ApiClient::**getViews**(*string* $path, *?GetViewsParams* \\$params): *PageViews*\n\n### Parser\n\n- Parser::**addTagReplaceRule**(*string* $tag, *string* \\$toTag): *Parser*\n- Parser::**addTagReplaceRules**(*array* $rules): *Parser*\n- Parser::**hasTagReplaceRule**(*string* $tag): *bool*\n- Parser::**getTagReplaceRule**(*string* $tag): *string|false|null*\n- Parser::**setAllowedAttributes**(*?string[]* $attributes): *Parser*\n- Parser::**setDisallowedAttributes**(*string[]* $attributes): *Parser*\n- Parser::**htmlToTelegraphContent**(*string* $html): *NodeElement[]|string[]*\n- Parser::**telegraphContentToHtml**(*NodeElement[]* $content): *string*\n- Parser::**decodeTelegraphContent**(*string* $json): *NodeElement[]*\n\n## Tests\n\nTested on PHP 5.6, 7.2 and 8.0.\n\n```shell\nphp composer.phar test tests\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullform%2Ftelegraphus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullform%2Ftelegraphus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullform%2Ftelegraphus/lists"}