cleytonbonamigo/share-twitter
最新稳定版本:1.0.0
Composer 安装命令:
composer require cleytonbonamigo/share-twitter
包简介
PHP Client to share a Twitter with Media images
README 文档
README
Combination of API V1 and V2 for PHP with CURL instead of any other libraries, this is a pacjage that provides an easy and fast integration of Twitter.
For now, it's not possible to upload files with API V2, that's why it's a combination of them.
Installation
First you need to add the component to you composer.json.
composer require cleytonbonamigo/twitter-share
How to use
Firstly, you need to follow this tutorial.
- Request of an approved account;
- Once you have an approved developer account, you will need to create a Project;
- Enable read/write access for your Twitter app;
- Generate Consumer Keys and Authentication Tokens;
- Grab your Keys and Tokens from the twitter developer site.
Prepare settings
Settings are expected as below:
use CleytonBonamigo\ShareTwitter\Client; $settings = [ 'access_token' => access_token, 'access_token' => access_token, 'access_token_secret' => access_token_secret, 'consumer_key' => consumer_key, 'consumer_secret' => consumer_secret ]; $client = new Client($settings);
Endpoints
Media
$url = ''; //An URL or path to local file $return = $client->media()->uploadMediaFromUrl($url);
$tweet = [ 'text' => 'Text of your tweet :)', 'media' => [ //This param is optional 'media_ids' => [ 'media_id_string' //Returned at uploadMediaFromUrl() ] ] ]; $client->tweet()->create(['text' => 'Test new tweet post with image complete flux', 'media' => ['media_ids' => [$media->media_id_string]]]);
Contributing
Fork/download the code and run.
composer install
Copy test/config/.env.example to test/config/.env and add your credentials for testing.
To run tests
./vendor/bin/phpunit or composer test.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-07