{"id":15033688,"url":"https://github.com/j7mbo/twitter-api-php","last_synced_at":"2026-01-10T04:56:08.818Z","repository":{"id":7331971,"uuid":"8653545","full_name":"J7mbo/twitter-api-php","owner":"J7mbo","description":"The simplest PHP Wrapper for Twitter API v1.1 calls","archived":false,"fork":false,"pushed_at":"2020-04-14T17:33:08.000Z","size":89,"stargazers_count":1818,"open_issues_count":37,"forks_count":799,"subscribers_count":97,"default_branch":"master","last_synced_at":"2025-01-08T20:05:42.487Z","etag":null,"topics":["php","twitter","twitter-api","twitter-client","twitter-oauth","twitterapi","twitterapiexchange"],"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/J7mbo.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":"2013-03-08T15:23:25.000Z","updated_at":"2024-11-18T07:06:27.000Z","dependencies_parsed_at":"2022-07-12T15:03:07.743Z","dependency_job_id":null,"html_url":"https://github.com/J7mbo/twitter-api-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J7mbo%2Ftwitter-api-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J7mbo%2Ftwitter-api-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J7mbo%2Ftwitter-api-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J7mbo%2Ftwitter-api-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/J7mbo","download_url":"https://codeload.github.com/J7mbo/twitter-api-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234100180,"owners_count":18779766,"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","twitter-client","twitter-oauth","twitterapi","twitterapiexchange"],"created_at":"2024-09-24T20:22:22.654Z","updated_at":"2025-09-24T17:30:47.624Z","avatar_url":"https://github.com/J7mbo.png","language":"PHP","readme":"twitter-api-php\n===============\n\nSimple PHP Wrapper for Twitter API v1.1 calls\n\n[![Total Downloads](https://img.shields.io/packagist/dt/j7mbo/twitter-api-php.svg)](https://packagist.org/packages/j7mbo/twitter-api-php)\n[![Build Status](https://travis-ci.org/J7mbo/twitter-api-php.svg?branch=master)](https://travis-ci.org/J7mbo/twitter-api-php)\n[![Version](https://badge.fury.io/gh/j7mbo%2Ftwitter-api-php.svg)](https://packagist.org/packages/j7mbo/twitter-api-php)\n\n**[Changelog](https://github.com/J7mbo/twitter-api-php/wiki/Changelog)** ||\n**[Examples](https://github.com/J7mbo/twitter-api-php/wiki/Twitter-API-PHP-Wiki)** ||\n**[Wiki](https://github.com/J7mbo/twitter-api-php/wiki)**\n\n[Instructions in StackOverflow post here](http://stackoverflow.com/questions/12916539/simplest-php-example-retrieving-user-timeline-with-twitter-api-version-1-1/15314662#15314662) with examples. This post shows you how to get your tokens and more. \nIf you found it useful, please upvote / leave a comment! :)\n\nThe aim of this class is simple. You need to:\n\n- Include the class in your PHP code\n- [Create a twitter app on the twitter developer site](https://dev.twitter.com/apps/)\n- Enable read/write access for your twitter app\n- Grab your access tokens from the twitter developer site\n- [Choose a twitter API URL to make the request to](https://dev.twitter.com/docs/api/1.1/)\n- Choose either GET / POST (depending on the request) \n- Choose the fields you want to send with the request (example: `array('screen_name' =\u003e 'usernameToBlock')`)\n\nYou really can't get much simpler than that. The above bullet points are an example of how to use the class for a POST request to block a user, and at the bottom is an example of a GET request.\n\nInstallation\n------------\n\n**Normally:** If you *don't* use composer, don't worry - just include TwitterAPIExchange.php in your application.\n\n```php\nrequire_once('TwitterAPIExchange.php');\n```\n\n**Via Composer:**\n\n```bash\ncomposer require j7mbo/twitter-api-php\n```\n\nHow To Use\n----------\n\n#### Set access tokens ####\n\n```php\n$settings = array(\n    'oauth_access_token' =\u003e \"YOUR_OAUTH_ACCESS_TOKEN\",\n    'oauth_access_token_secret' =\u003e \"YOUR_OAUTH_ACCESS_TOKEN_SECRET\",\n    'consumer_key' =\u003e \"YOUR_CONSUMER_KEY\",\n    'consumer_secret' =\u003e \"YOUR_CONSUMER_SECRET\"\n);\n```\n\n#### Choose URL and Request Method ####\n\n```php\n$url = 'https://api.twitter.com/1.1/blocks/create.json';\n$requestMethod = 'POST';\n```\n\n#### Choose POST fields (or PUT fields if you're using PUT) ####\n\n```php\n$postfields = array(\n    'screen_name' =\u003e 'usernameToBlock', \n    'skip_status' =\u003e '1'\n);\n```\n\n#### Perform the request! ####\n\n```php\n$twitter = new TwitterAPIExchange($settings);\necho $twitter-\u003ebuildOauth($url, $requestMethod)\n    -\u003esetPostfields($postfields)\n    -\u003eperformRequest();\n```\n\nGET Request Example\n-------------------\n\nSet the GET field BEFORE calling buildOauth(); and everything else is the same:\n\n```php\n$url = 'https://api.twitter.com/1.1/followers/ids.json';\n$getfield = '?screen_name=J7mbo';\n$requestMethod = 'GET';\n\n$twitter = new TwitterAPIExchange($settings);\necho $twitter-\u003esetGetfield($getfield)\n    -\u003ebuildOauth($url, $requestMethod)\n    -\u003eperformRequest();\n```\n\nThat is it! Really simple, works great with the 1.1 API. Thanks to @lackovic10 and @rivers on SO!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj7mbo%2Ftwitter-api-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj7mbo%2Ftwitter-api-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj7mbo%2Ftwitter-api-php/lists"}