nawaf/laravel-x
最新稳定版本:1.0.0
Composer 安装命令:
composer require nawaf/laravel-x
包简介
A Laravel package providing a simple and elegant wrapper around Abraham\TwitterOAuth, allowing seamless integration with the X (formerly Twitter) API in Laravel applications.
README 文档
README
Laravel X (formerly Twitter)
A Laravel package providing a simple and elegant wrapper around Abraham\TwitterOAuth, allowing seamless integration with the X (formerly Twitter) API in Laravel applications.
📦 Installation
Install the package via Composer:
composer require nawaf/laravel-x
The package will automatically register the service provider and facade.
⚙️ Configuration
Publish the configuration file using Artisan:
php artisan vendor:publish --provider="Nawaf\LaravelX\XServiceProvider"
This will create a config/x.php file. Then, add your X (Twitter) API credentials in your .env file:
CONSUMER_KEY=your_consumer_key CONSUMER_SECRET=your_consumer_secret ACCESS_TOKEN=your_access_token ACCESS_TOKEN_SECRET=your_access_token_secret
🚀 Usage
You can use the X facade to access any method provided by the underlying TwitterOAuth library:
// Example: posting a tweet $response = X::post('statuses/update', ['status' => 'Hello X!']); // Example: fetching your timeline $tweets = X::get('statuses/home_timeline');
Or, inject the service directly:
use Nawaf\LaravelX\X; public function __construct(X $x) { $this->x = $x; } public function index() { $tweets = $this->x->get('statuses/home_timeline'); return $tweets; }
Any method called on the X facade or service will be forwarded to the underlying TwitterOAuth connection.
📝 Methods
Since this package wraps Abraham\TwitterOAuth, you can use any of its methods, for example:
get($endpoint, $parameters = [])post($endpoint, $parameters = [])upload($endpoint, $parameters = [])
OAuth2/ methods if needed
Refer to the TwitterOAuth documentation for full details.
🤝 Contribution
We welcome all contributions to improve the project. You can open an Issue or submit a Pull Request.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-02
