{"id":26085263,"url":"https://github.com/codezero-be/twitter","last_synced_at":"2026-03-05T07:01:44.978Z","repository":{"id":20194907,"uuid":"23466091","full_name":"codezero-be/twitter","owner":"codezero-be","description":"Simple Twitter API wrapper","archived":false,"fork":false,"pushed_at":"2015-12-12T15:19:29.000Z","size":26,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-08T01:22:11.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/codezero-be.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-29T14:12:09.000Z","updated_at":"2017-01-14T12:20:36.000Z","dependencies_parsed_at":"2022-07-27T01:02:21.774Z","dependency_job_id":null,"html_url":"https://github.com/codezero-be/twitter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/codezero-be/twitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Ftwitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Ftwitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Ftwitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Ftwitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codezero-be","download_url":"https://codeload.github.com/codezero-be/twitter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Ftwitter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30113111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-03-09T05:58:03.163Z","updated_at":"2026-03-05T07:01:44.740Z","avatar_url":"https://github.com/codezero-be.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Twitter API Wrapper\n\n[![Build Status](https://travis-ci.org/codezero-be/twitter.svg?branch=master)](https://travis-ci.org/codezero-be/twitter) [![Latest Stable Version](https://poser.pugx.org/codezero/twitter/v/stable.svg)](https://packagist.org/packages/codezero/twitter) [![Total Downloads](https://poser.pugx.org/codezero/twitter/downloads.svg)](https://packagist.org/packages/codezero/twitter) [![License](https://poser.pugx.org/codezero/twitter/license.svg)](https://packagist.org/packages/codezero/twitter)\n\nThis package hides away the complexity of \"talking\" to the Twitter API, but instead offers a few simple functions to execute some basic queries.\n\n## Features\n\n- All queries require an **API key** and **API secret** to generate App Credentials\n- Authorization will be triggered automatically behind the scenes\n- Fetch a user's tweets with a single method call\n- Search Twitter for a hash tag or keyword\n- Get the results in standard JSON format, or use our simplified `Tweet` objects\n- Optional Caching (only [Laravel](http://www.laravel.com/ \"Laravel\") implementation included, see [codezero-be/courier](https://github.com/codezero-be/courier))\n- Optional [Laravel](http://www.laravel.com/ \"Laravel\") ServiceProvider included\n\n## Installation\n\nInstall this package through Composer:\n\n``` \n\"require\": {\n    \"codezero/twitter\": \"1.*\"\n}\n```\n\n## Setup\n\n### Laravel Setup\n\nAfter installing, update your Laravel `config/app.php` file to include a reference to this package's service provider in the providers array:\n\n``` \n'providers' =\u003e [\n    'CodeZero\\Twitter\\TwitterServiceProvider'\n]\n```\n\nNext, publish the package config file and [enter your API credentials](#edit-configuration).\n\nWith Laravel 4.*:\n\n``` \nphp artisan config:publish codezero/twitter\n```\n\nWith Laravel 5.*:\n\n``` \nphp artisan vendor:publish --provider=\"CodeZero\\Twitter\\TwitterServiceProvider\"\n```\n\n### Manual Setup\n\nSpecify the location of your config file. An example configuration file is included in the `src/config` folder. You can put this anywhere you want.\n\n``` \n$config = '/path/to/configFile.php';\n```\n\nCreate Twitter instance:\n\n``` \nuse CodeZero\\Twitter\\Twitter;\n$twitter = new Twitter($config);\n```\n\n## Edit Configuration\n\nYour configuration file should look like the following:\n\n``` \n\u003c?php\nreturn [\n    'base_url' =\u003e 'https://api.twitter.com/',\n    'api_version' =\u003e '1.1',\n    'api_key' =\u003e '',\n    'api_secret' =\u003e ''\n];\n```\n\nBe sure to enter your API key and API secret. Twitter requires this for all requests. Also, do not include the API version in the `base_url` as this would break the authorization request.\n\n## Usage\n\n### Set options\n\nThe number of results to return. Each Twitter request has a maximum limit. If you specify a `$count` greater than this limit, the maximum results will be returned. (Default: `10`)\n\n``` \n$count = 10;\n```\n\nThe number of minutes the results of the query should be cached. Twitter sets a request limit per hour, so caching is a good idea. Setting this to `0` (zero) will disable caching. (Default: `30`)\n\n``` \n$cacheMinutes = 30;\n```\n\nThis package includes a `Tweet` object which greatly simplifies the returned results. If you want the full JSON response to be returned, set this to `false`. (Default: `true`)\n\n``` \n$returnEntities = true;\n```\n\n### Get tweets\n\n``` \ntry\n{\n    $username = 'laravelphp'; //=\u003e Example...\n    $tweets = $twitter-\u003egetTweetsFromUser($username, $count, $cacheMinutes, $returnEntities);\n}\ncatch (\\CodeZero\\Twitter\\TwitterException $e)\n{\n    $error = $e-\u003egetMessage(); //=\u003e user not found etc.\n}\n```\n\n### Response formats\n\n#### JSON\n\nIf you `$returnEntities` is `false`, you get a `CodeZero\\Courier\\Response` object, which contains the actual JSON response.\n\n``` \n$tweets = $twitter-\u003egetTweetsFromUser($username);\n\necho $tweets; //=\u003e Print the JSON\n$json = $tweets-\u003egetBody(); //=\u003e Returns the JSON\n$array = $tweets-\u003etoArray(); //=\u003e Convert JSON to an array\n```\n\nFor more information on this `Response` object, refer to [codezero-be/courier](https://github.com/codezero-be/courier).\n\n#### Tweets\n\nIf you `$returnEntities` is `true`, you get an array of `CodeZero\\Twitter\\Entities\\Tweet` objects. This is a very simplified `Tweet` object, which only contains the most useful info about the tweet and its user.\n\n``` \n$tweets = $twitter-\u003egetTweetsFromUser($username);\n```\n\n\n\n``` \nforeach ($tweets as $tweet)\n{\n    $user = $tweet-\u003euser();\n    $tweetOwner = $user-\u003egetName();\n    $tweetUsername = $user-\u003egetUsername();\n    $tweetText = $tweet-\u003egetText();\n    $tweetDate = $tweet-\u003egetCreatedAt();\n}\n```\n\nFor an overview of all available `Tweet` and `User` information, take a look at the source.\n\n## Available Requests\n\n### Get tweets from a user\n\n``` \n$username = 'laravelphp';\n$tweets = $twitter-\u003egetTweetsFromUser($username, $count, $cacheMinutes, $returnEntities);\n```\n\n### Search for tweets with a hash tag or keyword\n\n``` \n$query = '#laravel';\n$tweets = $twitter-\u003esearchTweets($query, $count, $cacheMinutes, $returnEntities);\n```\n\n### That's all for now...\n\n---\n\n[![Analytics](https://ga-beacon.appspot.com/UA-58876018-1/codezero-be/twitter)](https://github.com/igrigorik/ga-beacon)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodezero-be%2Ftwitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodezero-be%2Ftwitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodezero-be%2Ftwitter/lists"}