This commit is contained in:
2025-11-20 16:34:30 +01:00
parent 15d1a30e88
commit 4e4351e833
631 changed files with 130125 additions and 36318 deletions

View File

@@ -2,6 +2,8 @@
This package provides Twitter OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).
**As I (Evan) have closed all my X accounts, I can no longer verify this library's features myself. If you are willing to take maintenance of this library, please get in touch!**
## Installation
To install, use composer:
@@ -31,14 +33,15 @@ $provider = new Smolblog\OAuth2\Client\Provider\Twitter([
if (!isset($_GET['code'])) {
unset($_SESSION['oauth2state']);
unset($_SESSION['oauth2verifier']);
// Optional: The default scopes are tweet.read, users.read,
// and offline.access. You can change them like this:
// users.email and offline.access. You can change them like this:
$options = [
scope => [
tweet.read,
tweet.write,
tweet.moderate.write,
users.email,
users.read,
follows.read,
follows.write,
@@ -55,8 +58,8 @@ if (!isset($_GET['code'])) {
bookmark.read,
bookmark.write,
],
];
];
// If we don't have an authorization code then get one
$authUrl = $provider->getAuthorizationUrl($options);
@@ -90,7 +93,7 @@ if (!isset($_GET['code'])) {
$user = $provider->getResourceOwner($token);
// Use these details to create a new profile
printf('Hello %s!', $user->getName());
printf('Hello %s (%s)!', $user->getName(), $user->getEmail());
} catch (Exception $e) {
echo '<pre>';
@@ -125,4 +128,4 @@ touch._
## License
The Modified 3-clause BSD License (BSD). Please see [License File](https://github.com/smolblog/oauth2-twitter/blob/main/LICENSE.md) for more information.
The Modified 3-clause BSD License (BSD). Please see [License File](https://github.com/smolblog/oauth2-twitter/blob/main/LICENSE.md) for more information.