Skip to content

Migrate to Twitter API v2#19

Open
angristan wants to merge 1 commit intoArthurHoaro:masterfrom
angristan:feature/issue-18
Open

Migrate to Twitter API v2#19
angristan wants to merge 1 commit intoArthurHoaro:masterfrom
angristan:feature/issue-18

Conversation

@angristan
Copy link
Contributor

Fixes #18

Twitter API v1.1 was deprecated in 2023, breaking the plugin. This PR migrates to API v2 using the noweh/twitter-api-v2-php library.

Works on my Shaarli instance (0.15, PHP 8.2) 🥳

Changes

  • Replace bundled TwitterAPIExchange with noweh/twitter-api-v2-php Composer package
    • I didn't vendor it in git, I guess creating the releases with the vendor folder is enough?
  • Pin psr/http-message: ^1.0 for compatibility with Shaarli's Slim version
  • Bump PHP requirement from 7.1 to 7.4
  • Update CI to test PHP 7.4, 8.0, 8.1, 8.2
  • Update documentation for new Twitter Developer Portal
    • We can add a new screenshot, but the naming of API Key and Secret and Access Token and Secret in the dev portal matches the config options now, so it's self-explanatory I think

Breaking changes

  • PHP 7.4+ now required
  • Twitter app must be inside a Project (standalone apps don't work with API v2)

Copilot AI review requested due to automatic review settings December 13, 2025 10:05
Replace deprecated Twitter API v1.1 with v2 using noweh/twitter-api-v2-php.
Fixes ArthurHoaro#18.

- Bump PHP requirement to 7.4+
- Add noweh/twitter-api-v2-php dependency
- Pin psr/http-message ^1.0 for Shaarli compatibility
- Remove bundled TwitterAPIExchange library
- Update error handling for v2 response format
- Update CI to PHP 7.4-8.2
- Update documentation with new Twitter Developer Portal instructions
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Shaarli2Twitter plugin from the deprecated Twitter API v1.1 to API v2, addressing a breaking change that occurred in 2023. The migration replaces a bundled library with a modern Composer package and updates the codebase to work with current Twitter/X API requirements.

Key Changes

  • Replaced bundled TwitterAPIExchange library with noweh/twitter-api-v2-php package
  • Enhanced error handling with try-catch blocks and improved error message parsing
  • Updated minimum PHP version from 7.1 to 7.4 and CI configuration to test modern PHP versions (7.4, 8.0, 8.1, 8.2)

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
shaarli2twitter/shaarli2twitter.php Migrated tweet posting to Twitter API v2, added composer autoload, improved error handling with try-catch and updated error message parsing
shaarli2twitter/TwitterApi/TwitterAPIExchange.php Removed deprecated v1.1 API library (362 lines deleted)
shaarli2twitter/TwitterApi/LICENSE.md Removed license file for old bundled library
composer.json Added noweh/twitter-api-v2-php ^3.0 and psr/http-message ^1.0 dependencies, bumped PHP requirement to 7.4+
README.md Updated documentation for Twitter API v2 setup process, reflecting new Developer Portal structure and requirements
.travis.yml Updated CI to test PHP 7.4, 8.0, 8.1, 8.2, and nightly, changed dist from trusty to focal
.gitignore Added .phpunit.result.cache to ignored files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Twitter/X API v2

1 participant