cwramsey / gnip-rules
1.0.1
2016-04-06 20:13 UTC
Requires
- php: ^7.0
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- phpunit/phpunit: ^5.3
- sp4ceb4r/better-ini: ^0.1.1
This package is not auto-updated.
Last update: 2025-04-12 21:54:04 UTC
README
This is a simple library for interacting with the GNIP Powertrack rules API.
Installation
Run $ composer require cwramsey/gnip-rules
Usage
Creating a client
require_once(__DIR__ . '/vendor/autoload.php'); use Gnip\GnipRules; $username = ''; $password = ''; $gnip_account_name = 'your_account_name'; $data_source = 'twitter'; $stream_label = 'stream_name'; $client = new GnipRules($username, $password, $gnip_account_name, $data_source, $stream_label);
Reading your rules
$rules = $client->read(); // returns a Gnip\RuleList iterable with your full rule list. foreach ($rules as $rule) { echo $rule->getValue() . " - " . $rule->getTag(); }
Creating new rules
$new_rules = [ [ 'value' => 'rule1', 'tag' => '123' ], [ 'value' => 'rule2', 'tag' => '123' ], [ 'value' => 'rule3', 'tag' => '123' ], ]; $updated_rules = $client->create($new_rules); // returns a GnipRuleList iterable with updated rules
Deleting rules
$rules_to_delete = [ [ 'value' => 'rule1', ], [ 'value' => 'rule2', ], [ 'value' => 'rule3', ], ]; // please note that Gnip does not allow you to delete by tag, so you must only include the `value`. $updated_rules = $client->delete($rules_to_delete); // returns a GnipRuleList iterable with updated rules
TODO
- Add data collector support
- Add support for PowerTrack 2.0