{"id":20519834,"url":"https://github.com/jabranr/fetchwitter","last_synced_at":"2025-04-14T02:12:05.562Z","repository":{"id":15465443,"uuid":"18198643","full_name":"jabranr/fetchwitter","owner":"jabranr","description":"PHP client to fetch tweets from Twitter API v1.1 using OAuth authentication/authorization","archived":false,"fork":false,"pushed_at":"2015-08-13T13:38:06.000Z","size":1055,"stargazers_count":15,"open_issues_count":6,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T04:55:22.068Z","etag":null,"topics":["oauth-authentication","php","twitter-api"],"latest_commit_sha":null,"homepage":"http://j.mp/fetchwitter","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabranr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-28T02:26:45.000Z","updated_at":"2022-01-29T14:07:56.000Z","dependencies_parsed_at":"2022-08-25T16:51:54.452Z","dependency_job_id":null,"html_url":"https://github.com/jabranr/fetchwitter","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabranr%2Ffetchwitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabranr%2Ffetchwitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabranr%2Ffetchwitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabranr%2Ffetchwitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabranr","download_url":"https://codeload.github.com/jabranr/fetchwitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248809051,"owners_count":21164896,"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":["oauth-authentication","php","twitter-api"],"created_at":"2024-11-15T22:16:32.279Z","updated_at":"2025-04-14T02:12:05.536Z","avatar_url":"https://github.com/jabranr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Fetchwitter [![Build Status](https://travis-ci.org/jabranr/fetchwitter.svg?branch=master)](https://travis-ci.org/jabranr/fetchwitter) [![Latest Stable Version](https://poser.pugx.org/fetchwitter/fetchwitter/v/stable.svg)](https://packagist.org/packages/fetchwitter/fetchwitter) [![Total Downloads](https://poser.pugx.org/fetchwitter/fetchwitter/downloads.svg)](https://packagist.org/packages/fetchwitter/fetchwitter) [![Analytics](https://ga-beacon.appspot.com/UA-50688851-1/fetchwitter)](https://github.com/igrigorik/ga-beacon)\n\nPHP library to fetch tweets from Twitter API v1.1 using OAuth authentication/authorization. Fetchwitter provides easy to use methods for basic functionality such as tweets or hashtag search, or fetch a user timeline feed. All you need are Twitter app key and secret to get you going.\n\n\u003cblockquote\u003eNote: The authentication flow uses Twitter’s App-Only Authentication.\u003c/blockquote\u003e\n\n## Install\nFetchwitter can be installed using one of following methods:\n\n* [Download latest release](https://github.com/jabranr/Fetchwitter/releases/latest)\n\n#### Using Composer (Recommended)\nAdd as dependency into your `composer.json` file.\n``` json\n{\n\t\"require\": {\n\t\t\"fetchwitter/fetchwitter\": \"\u003e=1.0.8\"\n\t}\n}\n```\n\nUse [Composer](http://getcomposer.org) to install.\n``` shell\n$ composer install\n```\n\nRequire/include the file into your project\n```php\nrequire 'path/to/vendor/fetchwitter/autoload.php'\n```\n\n## Basic Example\nThe instance initialization automatically fetches the access token using OAuth flow and makes it available to the class. An existing access token can also be set manually as follow.\n\nThe configuration arguments can be passed as string, indexed array or associative array. Basically 2 arguments are required that are API Key and Secret. If you already have an access token you can optionally pass it as third parameter to bypass the automatic OAuth flow and make API calls using your access token. Here is a very basic example to start with.\n\nPass arguments as associative array:\n``` php\n$config = array(\n\t'api_key' =\u003e 'API_KEY',\n\t'api_secret' =\u003e 'API_SECRET',\n\t'access_token' =\u003e 'ACCESS_TOKEN', // optional\n);\n\ntry {\n\t$fw = new Fetchwitter($config);\n}\ncatch(Exception $e) {\n\techo $e-\u003egetMessage();\n}\n\n```\n\nor pass arguments as indexed array:\n```php\n$config = array( 'API_KEY', 'API_SECRET', 'ACCESS_TOKEN' /* optional */ );\n\ntry {\n\t$fw = new Fetchwitter($config);\n}\ncatch(Exception $e) {\n\techo $e-\u003egetMessage();\n}\n\n```\n\nor pass arguments as strings:\n```php\ntry {\n\t$fw = new Fetchwitter( 'API_KEY', 'API_SECRET', 'ACCESS_TOKEN' /* optional */ );\n}\ncatch(Exception $e) {\n\techo $e-\u003egetMessage();\n}\n```\n\n### Configuration \u0026amp; Initialization\n\n+ Register a new app at [Twitter Application Manager](https://apps.twitter.com) and get API key and secret.\n+ Initialize a new instance of Fetchwitter as explained above.\n+ Make API requests as exampled below:\n\nMake any GET request i.e. fetch user timeline\n```php\n$fw-\u003eget('statuses/user_timeline', array(\n\t'count' =\u003e 2,\n\t'screen_name' =\u003e 'jabranr'\n\t)\n);\n```\n\nSearch tweets with a hashtag\n```php\n$fw-\u003eget('search/tweets', array(\n\t'count' =\u003e 2,\n\t'q' =\u003e '#TwitterAPI',\n\t'result_type' =\u003e 'recent'\n\t)\n);\n```\n\nOnce a valid instance of Fetchwitter is created, it automatically goes through an [App-Only Authentication](https://dev.twitter.com/docs/auth/application-only-auth) and gets a valid `access_token` from Twitter API or returns appropriate error message in case of failure. \n\n\u003cblockquote\u003eThe method will throw an Exception in case of any missing parameters or returns error message from API in JSON format otherwise.\u003c/blockquote\u003e\n\nFollowing methods are available for a valid and successfully established connection with API.\n\n### Helper method `toTweet()`\nUse `toTweet( $text )` method to convert the static Tweet to formatted Tweet with Mentions, Hashtags and Links properly linked. The method takes the Tweet in string format as parameter and returns a formatted Tweet.\n\n**Use:**\n\n``` php\n$tweet = $fetchwitter-\u003etoTweet( string $tweet );\n```\n\n**Example:**\n\n**Static Tweet as it comes from the API feed:**\n\nThis is a #test tweet by @jabranr to confirm methods from #Fetchwitter. More at https://github.com/jabranr/fetchwitter\n\n**Formatted Tweet using `toTweet()` method:**\n\nThis is a [#test](https://twitter.com/search?q=%23test) tweet by [@jabranr](https://twitter.com/jabranr) to confirm methods from [#Fetchwitter](https://twitter.com/search?q=%23Fetchwitter). More at [https://github.com/jabranr/fetchwitter](https://github.com/jabranr/fetchwitter)\n\nA [JavaScript version](https://gist.github.com/jabranr/68515719cde0653d641d) is also available.\n\n#### Disclaimer\nI made this library just for learning purpose and have been improving it. A lot of inspiration has come from [Abraham's comprehensive TwitterOAuth](https://github.com/abraham/twitteroauth) library. If you need a complete Twitter API support then please use Abraham's library instead.\n\n#### Issues reporting/tracking\n[Github Repo Issues](https://github.com/jabranr/fetchwitter/issues)\n\n#### Contribution\nIn order to contribute:\n\n1. Fork the repository\n2. Create a new branch\n3. Once you are ready then make a pull request\n\n#### License\nMIT License - [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)\n\n\u0026copy; [@jabranr](https://twitter.com/jabranr) - 2014-2-15\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabranr%2Ffetchwitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabranr%2Ffetchwitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabranr%2Ffetchwitter/lists"}