{"id":13608753,"url":"https://github.com/dg/twitter-php","last_synced_at":"2025-12-24T21:48:19.868Z","repository":{"id":46085052,"uuid":"501252","full_name":"dg/twitter-php","owner":"dg","description":"Small and easy PHP library for sending messages to Twitter and receiving statuses. ","archived":false,"fork":false,"pushed_at":"2022-11-29T17:24:25.000Z","size":136,"stargazers_count":539,"open_issues_count":8,"forks_count":149,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-04-09T15:02:31.292Z","etag":null,"topics":["php","twitter","twitter-api"],"latest_commit_sha":null,"homepage":"https://nette.org","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"dg","custom":"https://nette.org/make-donation?to=twitter-php"}},"created_at":"2010-02-03T20:29:37.000Z","updated_at":"2025-02-14T21:49:32.000Z","dependencies_parsed_at":"2023-01-23T11:15:20.584Z","dependency_job_id":null,"html_url":"https://github.com/dg/twitter-php","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Ftwitter-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Ftwitter-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Ftwitter-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Ftwitter-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dg","download_url":"https://codeload.github.com/dg/twitter-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248605316,"owners_count":21132149,"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":["php","twitter","twitter-api"],"created_at":"2024-08-01T19:01:29.680Z","updated_at":"2025-12-24T21:48:19.862Z","avatar_url":"https://github.com/dg.png","language":"PHP","funding_links":["https://github.com/sponsors/dg","https://nette.org/make-donation?to=twitter-php"],"categories":["PHP"],"sub_categories":[],"readme":"[Twitter for PHP](https://phpfashion.com/twitter-for-php)  [![Buy me a coffee](https://files.nette.org/images/coffee1s.png)](https://nette.org/make-donation?to=twitter-php)\n================================\n\n[![Downloads this Month](https://img.shields.io/packagist/dm/dg/twitter-php.svg)](https://packagist.org/packages/dg/twitter-php)\n\nTwitter for PHP is a very small and easy-to-use library for sending\nmessages to Twitter and receiving status updates.\n\nIt requires PHP 5.4 or newer with CURL extension and is licensed under the New BSD License.\nYou can obtain the latest version from our [GitHub repository](https://github.com/dg/twitter-php)\nor install it via Composer:\n\n\tcomposer require dg/twitter-php\n\n\n[Support Me](https://github.com/sponsors/dg)\n--------------------------------------------\n\nDo you like Nette DI? Are you looking forward to the new features?\n\n[![Buy me a coffee](https://files.nette.org/icons/donation-3.svg)](https://github.com/sponsors/dg)\n\nThank you!\n\n\nUsage\n-----\nSign in to the https://twitter.com and register an application from the https://apps.twitter.com page. Remember\nto never reveal your consumer secrets. Click on My Access Token link from the sidebar and retrieve your own access\ntoken. Now you have consumer key, consumer secret, access token and access token secret.\n\nCreate object using application and request/access keys\n\n```php\nuse DG\\Twitter\\Twitter;\n\n$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);\n```\n\nThe send() method updates your status. The message must be encoded in UTF-8:\n\n```php\n$twitter-\u003esend('I am fine today.');\n```\n\nThe load() method returns the 20 most recent status updates\nposted by you:\n\n```php\n$statuses = $twitter-\u003eload(Twitter::ME);\n```\n\nor posted by you and your friends:\n\n```php\n$statuses = $twitter-\u003eload(Twitter::ME_AND_FRIENDS);\n```\nor most recent mentions for you:\n\n```php\n$statuses = $twitter-\u003eload(Twitter::REPLIES);\n```\nExtracting the information from the channel is easy:\n\n```php\nforeach ($statuses as $status) {\n\techo \"message: \", Twitter::clickable($status);\n\techo \"posted at \" , $status-\u003ecreated_at;\n\techo \"posted by \" , $status-\u003euser-\u003ename;\n}\n```\n\nThe static method `Twitter::clickable()` makes links, mentions and hash tags in status clickable.\n\nThe authenticate() method tests if user credentials are valid:\n\n```php\nif (!$twitter-\u003eauthenticate()) {\n\tdie('Invalid name or password');\n}\n```\n\nThe search() method provides searching in twitter statuses:\n\n```php\n$results = $twitter-\u003esearch('#nette');\n```\n\nThe returned result is a again array of statuses.\n\n\nError handling\n--------------\n\nAll methods throw a `DG\\Twitter\\Exception` on error:\n\n```php\ntry {\n\t$statuses = $twitter-\u003eload(Twitter::ME);\n} catch (DG\\Twitter\\Exception $e) {\n\techo \"Error: \", $e-\u003egetMessage();\n}\n```\n\nAdditional features\n-------------------\n\nThe `authenticate()` method tests if user credentials are valid:\n\n```php\nif (!$twitter-\u003eauthenticate()) {\n\tdie('Invalid name or password');\n}\n```\n\nOther commands\n--------------\n\nYou can use all commands defined by [Twitter API 1.1](https://dev.twitter.com/rest/public).\nFor example [GET statuses/retweets_of_me](https://dev.twitter.com/rest/reference/get/statuses/retweets_of_me)\nreturns the array of most recent tweets authored by the authenticating user:\n\n```php\n$statuses = $twitter-\u003erequest('statuses/retweets_of_me', 'GET', ['count' =\u003e 20]);\n```\n\nChangelog\n---------\nv4.1 (11/2019)\n- added Delete Method (#68)\n- token is optional throughout + supply get() method\n\nv4.0 (2/2019)\n- requires PHP 7.1 and uses its advantages like typehints, strict types etc.\n- class Twitter is now DG\\Twitter\\Twitter\n- class TwitterException is now DG\\Twitter\\Exception\n\nv3.8 (2/2019)\n- Twitter::sendDirectMessage() uses new API\n- Twitter::clickable: added support for $status-\u003efull_text (#60)\n\nv3.7 (3/2018)\n- minimal required PHP version changed to 5.4\n- Twitter::send() added $options\n- Twitter::clickable() now works only with statuses and entites\n- fixed coding style\n\nv3.6 (8/2016)\n- added loadUserFollowersList() and sendDirectMessage()\n- Twitter::send() allows to upload multiple images\n- changed http:// to https://\n\nv3.5 (12/2014)\n- allows to send message starting with @ and upload file at the same time in PHP \u003e= 5.5\n\nv3.4 (11/2014)\n- cache expiration can be specified as string\n- fixed some bugs\n\nv3.3 (3/2014)\n- Twitter::send($status, $image) can upload image\n- added Twitter::follow()\n\nv3.2 (1/2014)\n- Twitter API uses SSL OAuth\n- Twitter::clickable() supports media\n- added Twitter::loadUserInfoById() and loadUserFollowers()\n- fixed Twitter::destroy()\n\nv3.1 (3/2013)\n- Twitter::load() - added third argument $data\n- Twitter::clickable() uses entities; pass as parameter status object, not just text\n- added Twitter::$httpOptions for custom cURL configuration\n\nv3.0 (12/2012)\n- updated to Twitter API 1.1. Some stuff deprecated by Twitter was removed:\n\t- removed RSS, ATOM and XML support\n\t- removed Twitter::ALL\n\t- Twitter::load() - removed third argument $page\n\t- Twitter::search() requires authentication and returns different structure\n- removed shortening URL using http://is.gd\n- changed order of Twitter::request() arguments to $resource, $method, $data\n\nv2.0 (8/2012)\n- added support for OAuth authentication protocol\n- added Twitter::clickable() which makes links, @usernames and #hashtags clickable\n- installable via `composer require dg/twitter-php`\n\nv1.0 (7/2008)\n- initial release\n\n\n-----\n(c) David Grudl, 2008, 2016 (https://davidgrudl.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdg%2Ftwitter-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdg%2Ftwitter-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdg%2Ftwitter-php/lists"}