{"id":15025746,"url":"https://github.com/mineur/twitter-stream-api","last_synced_at":"2026-02-24T20:40:36.141Z","repository":{"id":57017183,"uuid":"90676127","full_name":"mineur/twitter-stream-api","owner":"mineur","description":":baby_chick: Another Twitter stream PHP library to retrieve filtered tweets on hot.","archived":false,"fork":false,"pushed_at":"2017-07-16T21:56:59.000Z","size":68,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-09T20:04:15.192Z","etag":null,"topics":["guzzle","mineur","php71","streaming-api","streaming-data","twitter-streaming-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mineur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-08T21:58:09.000Z","updated_at":"2020-09-11T14:53:36.000Z","dependencies_parsed_at":"2022-08-22T09:40:45.930Z","dependency_job_id":null,"html_url":"https://github.com/mineur/twitter-stream-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineur%2Ftwitter-stream-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineur%2Ftwitter-stream-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineur%2Ftwitter-stream-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineur%2Ftwitter-stream-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mineur","download_url":"https://codeload.github.com/mineur/twitter-stream-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103865,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["guzzle","mineur","php71","streaming-api","streaming-data","twitter-streaming-api"],"created_at":"2024-09-24T20:02:57.455Z","updated_at":"2026-02-24T20:40:31.108Z","avatar_url":"https://github.com/mineur.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twitter Streaming API\n[![License](https://poser.pugx.org/mineur/twitter-stream-api/license)](https://packagist.org/packages/mineur/twitter-stream-api)\n[![Build Status](https://travis-ci.org/mineur/twitter-stream-api.svg?branch=master)](https://travis-ci.org/mineur/twitter-stream-api)\n[![Code Climate](https://codeclimate.com/github/mineur/twitter-stream-api/badges/gpa.svg)](https://codeclimate.com/github/mineur/twitter-stream-api)\n[![Latest Unstable Version](https://poser.pugx.org/mineur/twitter-stream-api/v/unstable)](https://packagist.org/packages/mineur/twitter-stream-api)\n[![Total Downloads](https://poser.pugx.org/mineur/twitter-stream-api/downloads)](https://packagist.org/packages/mineur/twitter-stream-api)\n\nAnother Twitter Stream PHP library. For now it just works on public stream, \nusing the filter method. \n\n## Index\n- [Installation](#installation)\n- [Basic init](#basic-initialization)\n    - [Callback method](#callback-method)\n    - [Filter by user](#filtering-tweets-by-user-id)\n    - [Filter by language](#filtering-keywords-by-language)\n- [The Tweet object](#the-tweet-object)\n- [Integrations (Symfony)](#integrations)\n- [Tests](#run-tests)\n- [To-do](#todos)\n\n## Installation\n```shell\ncomposer require mineur/twitter-stream-api:dev-master\n```\n\n## Basic initialization\nInstantiate the GuzzleHttpClient adapter with your Twitter api tokens. \nAnd start consuming Twitter's Stream with some keywords! :) \\\nIf you don't have your Twitter API credentials, check this: \n\u003ca href=\"https://dev.twitter.com/oauth/overview/application-owner-access-tokens\" \n   target=\"_blank\"\u003e\n    How to get your twitter access tokens\n\u003c/a\u003e\n```php\nuse Mineur\\TwitterStreamApi\\Http\\GuzzleStreamClient;\nuse Mineur\\TwitterStreamApi\\PublicStream;\n\n$streamClient = new GuzzleStreamClient(\n    'consumer_key',\n    'consumer_secret',\n    'access_token',\n    'access_token_secret'\n);\nPublicStream::open($streamClient)\n    -\u003elistenFor([\n        'your',\n        'keywords',\n        'list'\n    ])\n    -\u003econsume();\n```\n\u003e Working with the Twitter Stream you cannot open two stream lines with the same \n\u003e account. You should create another app account and raise a new instance of this \n\u003e library.\n\n### Callback method\nYou can also use a callback instead, if you want to modify the original output:\n```php\nuse Mineur\\TwitterStreamApi\\Tweet;\n\nPublicStream::open($streamClient)\n    -\u003elistenFor([\n        'your',\n        'keywords',\n        'list'\n    ])\n    -\u003edo(function(Tweet $tweet) {\n        echo \"$tweet-\u003egetUser() tweeted: $tweet-\u003egetText()\";\n    });\n```\n\n### Filtering tweets by user ID\nIn this example you'll only get the tweets of a user corresponding to its ID.\n```php\n$myTwitterId = '1234567';\nPublicStream::open($streamClient)\n    -\u003etweetedBy([\n        $myTwitterId\n    ])\n    -\u003econsume();\n```\n\n### Filtering keywords by language\nIn this example you'll only get the tweets on your keywords list write in spanish \nlanguage. \n```php\nPublicStream::open($streamClient)\n    -\u003elistenFor([\n        'keywords',\n        'list'\n    ])\n    -\u003esetLanguage('es')\n    -\u003econsume();\n```\n\n## The Tweet object\nOnce you receive the output from the PublicStream, let's say when you are using the `do` \ncallback function, the output will always be an hydrated Tweet value object.\n\\\nYou can access it with the following methods:\n* Using getters:\n```php\n// Get specific data from the object\n$tweet-\u003egetText();\n```\n* As an array:\n```php\n// Transform object to an array, then access to the data\n$aTweet = $tweet-\u003etoArray();\n$aTweet['text'];\n```\n* Serialized:\n```php\n// A complete serialized object to enqueue it, for example\n$tweet-\u003eserialized();\n```\n\n## Integrations\nFor Symfony integrations you can refer to this bundle: \n[Mineur Twitter Stream Api Bundle](https://github.com/mineur/twitter-stream-api-bundle)\n\n## Run tests\n```php\ncomposer install\n./bin/phpunit\n```\nTo check the coverage just add:\n```php\n./bin/phpunit --coverage-text\n```\n\n## Todo's\n* STREAMING_ENDPOINT should be changed by client, using simple string injection\n* Add links of the filters in documentation\n* Test the first version of this library using Unit testing\n* Handle when a user removes a tweet on the fly.\n* Add `filter_level` feature\n* Add track `location` feature","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmineur%2Ftwitter-stream-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmineur%2Ftwitter-stream-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmineur%2Ftwitter-stream-api/lists"}