williamsdb/php2micropost
Composer 安装命令:
composer require williamsdb/php2micropost
包简介
A library that makes posting to Wordpress Microposts from PHP simple.
关键字:
README 文档
README
php2Micropost
A simple library that allows posting to WordPress Microposts via the API.
Table of Contents
About The Project
I have accounts on plenty of microblogging sites (Twitter, Mastodon, Bluesky and even Threads) but they are all owned and controlled by someone else. I decided that I wanted something that I could use and manage, and a quick search came up with Michael Gbadebo's WordPress plugin called Microposts.
I installed this and after playing around for a while, I decided that it was just what I was looking for. However, it was quite cumbersome to make a post from a mobile device when I was out and about. What I wanted was a simple page from which I could post including an image so I built this connector.
Very much inspired by my php2Micropost project this package will allow you to easily integrate creating Microposts from your own code.
Built With
Getting Started
Running the script is very straightforward:
-
install composer
-
add php2Micropost
composer.phar require williamsdb/php2micropost
You can read more about how this all works in these blog posts.
Prerequisites
Requirements are very simple; it requires the following:
- PHP (I tested on v8.1.13)
- WordPress (I tested on 6.9.4)
- Michael Gbadebo's Micropost plugin
- a WordPress blog and an Application Password (see this post for details of how to do that).
Installation
- As above
Usage
Here's a few examples to get you started.
Setup and connect to WordPress
require __DIR__ . '/vendor/autoload.php'; use williamsdb\php2micropost\php2Micropost; $base_url = 'https://www.your-domain.com/wp-json/wp/v2'; $username = 'WordPress username with write permissions'; $password = 'Your 24-character Application Password'; $parseURL = false; $php2Micropost = new php2Micropost( base_url: $base_url, username: $username, password: $password, parseUrls: false, autoRotate: false ); $connection = $php2Micropost->wordpress_connect();
Sending post with only text
Text sent can either be plain text or HTML. If you send plain text and $parseURLs is TRUE then the text will be checked for URLs and if any found they will be wrapped in <a href="URL">URL</a>. If you are passing HTML then $parseURLs should be set to FALSE to retain the HTML.
$text = "This is a test post from php2Micropost. " . date('Y-m-d H:i:s'); // post with text and nothing else $response = $php2Micropost->post_to_wordpress( connection: $connection, text: $text, title: '', media: '', );
Uploading a post with a single image
Microposts only accepts a single image so that's all that is allowed here.
$image = "/Users/neilthompson/Downloads/IMG_9547.jpeg"; $text = "This is a test post from php2Micropost. " . date('Y-m-d H:i:s'); // post with text and nothing else $response = $php2Micropost->post_to_wordpress( connection: $connection, text: $text, title: '', media: $image, );
Adding tags to a post
If the tag already exists, it will be associated with the post; otherwise, it will be created.
$tags = ['test', 'php2Micropost', 'reading']; $text = "This is a test post from php2Micropost. " . date('Y-m-d H:i:s'); // post with text and nothing else $response = $php2Micropost->post_to_wordpress( connection: $connection, text: $text, title: '', media: $image, tags: $tags, );
Known Issues
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the GNU General Public License v3.0. See LICENSE for more information.
Contact
Bluesky - @spokenlikeageek.com
Mastodon - @spokenlikeageek
X - @spokenlikeageek
Website - https://spokenlikeageek.com
Project link - Github
Acknowledgments
williamsdb/php2micropost 适用场景与选型建议
williamsdb/php2micropost 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「wordpress」 「Microposts」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 williamsdb/php2micropost 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 williamsdb/php2micropost 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 williamsdb/php2micropost 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
ABsurge PHP SDK for feature flags and A/B testing
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2026-03-21