https://github.com/naffiq/yii2-twitter-api
Yii2 component wrapper for J7mbo/twitter-api-php
https://github.com/naffiq/yii2-twitter-api
Last synced: about 2 months ago
JSON representation
Yii2 component wrapper for J7mbo/twitter-api-php
- Host: GitHub
- URL: https://github.com/naffiq/yii2-twitter-api
- Owner: naffiq
- Created: 2017-03-30T12:04:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-18T07:09:36.000Z (about 5 years ago)
- Last Synced: 2025-02-27T21:08:58.087Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Yii2 Twitter API
[](https://codeclimate.com/github/naffiq/yii2-twitter-api/coverage)
[](https://codeclimate.com/github/naffiq/yii2-twitter-api)
[](https://travis-ci.org/naffiq/yii2-twitter-api)This package provides component wrapper for [J7mbo/twitter-api-php](https://github.com/J7mbo/twitter-api-php) library.
Basically it just helps you to move settings to your app config.## Installation
The preferred way to install this package is through [composer](https://getcomposer.org/):
```bash
$ composer require naffiq/yii2-twitter-api
```## Configuration
Add following code to your components config section:
```php
[
// Other components ...
'twitter' => [
'class' => 'naffiq\twitterapi\TwitterAPI',
'oauthAccessToken' => 'YOUR_OAUTH_ACCESS_TOKEN',
'oauthAccessTokenSecret' => 'YOUR_OAUTH_ACCESS_TOKEN',
'consumerKey' => 'YOUR_CONSUMER_KEY',
'consumerSecret' => 'YOUR_CONSUMER_SECRET'
]
]
// ...
];
```And we are ready to roll
## Usage
Once you set up the component, you can use all of the [J7mbo/twitter-api-php](https://github.com/J7mbo/twitter-api-php)
library's methods, just like this:
```php
get('twitter');$url = 'https://api.twitter.com/1.1/blocks/create.json';
$requestMethod = 'POST';
$postFields = [
'screen_name' => 'usernameToBlock',
'skip_status' => '1'
];$twitter->buildOauth($url, $requestMethod)
->setPostfields($postFields)
->performRequest();
```