codechap/x
最新稳定版本:v1
Composer 安装命令:
composer require codechap/x
包简介
Posts to your own X profile only.
README 文档
README
A simple PHP library for posting to X (Formerly Twitter) using the free tier.
Requirements
- PHP 8.2 or higher
Installation
composer require codechap/x
Code Quality
This library passes PHPStan analysis at level 8 (strictest level).
./vendor/bin/phpstan analyse
Example
<?php require 'vendor/autoload.php'; use codechap\x\X; use codechap\x\Msg; // Create thread messages $threadPartA = new Msg(); $threadPartA->set('content', 'Hello, X!'); $threadPartA->set('image', 'img-HrW6drkAzh4UqUaXD3o3H.jpeg'); $threadPartB = new Msg(); $threadPartB->set('content', 'Hello, X! This is the second message.'); $threadPartB->set('image', 'img-HrW6drkAzh4UqUaXD3o3H.jpeg'); // Initialize X client for thread $threadPoster = new X(); $threadPoster->set('apiKey', $apiKey); $threadPoster->set('apiKeySecret', $apiKeySecret); $threadPoster->set('accessToken', $accessToken); $threadPoster->set('accessTokenSecret', $accessTokenSecret); // Post thread $thread = [$threadPartA, $threadPartB]; $threadPoster->post($thread); echo "Thread posted successfully!\n";
<?php require 'vendor/autoload.php'; use codechap\x\X; use codechap\x\Msg; // Single post example $post = new X(); $post->set('apiKey', $apiKey); $post->set('apiKeySecret', $apiKeySecret); $post->set('accessToken', $accessToken); $post->set('accessTokenSecret', $accessTokenSecret); $msg = new Msg(); $msg->set('content', 'Hello, X!'); $msg->set('image', 'img-HrW6drkAzh4UqUaXD3o3H.jpeg'); $post->post($msg); echo "Single post successful!";
<?php require 'vendor/autoload.php'; use codechap\x\X; // Get your user info $client = new X(); $client->set('apiKey', $apiKey); $client->set('apiKeySecret', $apiKeySecret); $client->set('accessToken', $accessToken); $client->set('accessTokenSecret', $accessTokenSecret); $userInfo = $client->me(); echo "Hello, " . $userInfo['data']['name'] . "!\n";
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-07