samlitowitz / twitter-php-openapi
Twitter API v2 available endpoints
v2.0.0
2022-06-11 15:34 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
This package is auto-updated.
Last update: 2024-12-11 20:54:50 UTC
README
Twitter API v2 available endpoints
For more information, please visit https://developer.twitter.com/.
Installation & Usage
Requirements
PHP 7.4 and later. Should also work with PHP 8.0.
Composer
To install the bindings via Composer, add the following to composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/samlitowitz/twitter-php-openapi.git" } ], "require": { "samlitowitz/twitter-php-openapi": "*@dev" } }
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: OAuth2UserToken $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPI\Client\Api\BookmarksApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $id = 'id_example'; // string | The ID of the authenticated source User for whom to return results. $max_results = 56; // int | The maximum number of results. $pagination_token = 'pagination_token_example'; // string | This parameter is used to get the next 'page' of results. $tweet_fields = ["attachments","author_id","context_annotations","conversation_id","created_at","entities","geo","id","in_reply_to_user_id","lang","non_public_metrics","organic_metrics","possibly_sensitive","promoted_metrics","public_metrics","referenced_tweets","reply_settings","source","text","withheld"]; // string[] | A comma separated list of Tweet fields to display. $expansions = ["attachments.media_keys","attachments.poll_ids","author_id","entities.mentions.username","geo.place_id","in_reply_to_user_id","referenced_tweets.id","referenced_tweets.id.author_id"]; // string[] | A comma separated list of fields to expand. $media_fields = ["alt_text","duration_ms","height","media_key","non_public_metrics","organic_metrics","preview_image_url","promoted_metrics","public_metrics","type","url","variants","width"]; // string[] | A comma separated list of Media fields to display. $poll_fields = ["duration_minutes","end_datetime","id","options","voting_status"]; // string[] | A comma separated list of Poll fields to display. $user_fields = ["created_at","description","entities","id","location","name","pinned_tweet_id","profile_image_url","protected","public_metrics","url","username","verified","withheld"]; // string[] | A comma separated list of User fields to display. $place_fields = ["contained_within","country","country_code","full_name","geo","id","name","place_type"]; // string[] | A comma separated list of Place fields to display. try { $result = $apiInstance->getUsersIdBookmarks($id, $max_results, $pagination_token, $tweet_fields, $expansions, $media_fields, $poll_fields, $user_fields, $place_fields); print_r($result); } catch (Exception $e) { echo 'Exception when calling BookmarksApi->getUsersIdBookmarks: ', $e->getMessage(), PHP_EOL; }
API Endpoints
All URIs are relative to https://api.twitter.com
Models
- AddOrDeleteRulesRequest
- AddOrDeleteRulesResponse
- AddRulesRequest
- AnimatedGif
- AnimatedGifAllOf
- BlockUserMutationResponse
- BlockUserMutationResponseData
- BlockUserRequest
- BookmarkAddRequest
- BookmarkMutationResponse
- BookmarkMutationResponseData
- CashtagEntity
- CashtagFields
- ClientDisconnectedProblem
- ClientForbiddenProblem
- ClientForbiddenProblemAllOf
- ComplianceJob
- ComplianceJobStatus
- ComplianceJobType
- ConflictProblem
- ConnectionExceptionProblem
- ConnectionExceptionProblemAllOf
- ContextAnnotation
- ContextAnnotationDomainFields
- ContextAnnotationEntityFields
- CreateComplianceJobRequest
- CreateComplianceJobResponse
- DeleteRulesRequest
- DeleteRulesRequestDelete
- DisallowedResourceProblem
- DisallowedResourceProblemAllOf
- DuplicateRuleProblem
- DuplicateRuleProblemAllOf
- EntityIndicesInclusiveExclusive
- EntityIndicesInclusiveInclusive
- Error
- Expansions
- FieldUnauthorizedProblem
- FieldUnauthorizedProblemAllOf
- FilteredStreamingTweetResponse
- FilteredStreamingTweetResponseMatchingRulesInner
- FullTextEntities
- FullTextEntitiesAnnotationsInner
- FullTextEntitiesAnnotationsInnerAllOf
- GenericProblem
- Geo
- Get2ComplianceJobsIdResponse
- Get2ComplianceJobsResponse
- Get2ComplianceJobsResponseMeta
- Get2ListsIdFollowersResponse
- Get2ListsIdFollowersResponseMeta
- Get2ListsIdMembersResponse
- Get2ListsIdResponse
- Get2ListsIdTweetsResponse
- Get2SpacesByCreatorIdsResponse
- Get2SpacesIdBuyersResponse
- Get2SpacesIdResponse
- Get2SpacesIdTweetsResponse
- Get2SpacesResponse
- Get2SpacesSearchResponse
- Get2TweetsCountsAllResponse
- Get2TweetsCountsAllResponseMeta
- Get2TweetsCountsRecentResponse
- Get2TweetsIdLikingUsersResponse
- Get2TweetsIdQuoteTweetsResponse
- Get2TweetsIdQuoteTweetsResponseMeta
- Get2TweetsIdResponse
- Get2TweetsIdRetweetedByResponse
- Get2TweetsResponse
- Get2TweetsSampleStreamResponse
- Get2TweetsSearchAllResponse
- Get2TweetsSearchAllResponseMeta
- Get2TweetsSearchRecentResponse
- Get2TweetsSearchStreamResponse
- Get2UsersByResponse
- Get2UsersByUsernameUsernameResponse
- Get2UsersIdBlockingResponse
- Get2UsersIdBookmarksResponse
- Get2UsersIdFollowedListsResponse
- Get2UsersIdFollowersResponse
- Get2UsersIdFollowingResponse
- Get2UsersIdLikedTweetsResponse
- Get2UsersIdListMembershipsResponse
- Get2UsersIdMentionsResponse
- Get2UsersIdMentionsResponseMeta
- Get2UsersIdMutingResponse
- Get2UsersIdOwnedListsResponse
- Get2UsersIdPinnedListsResponse
- Get2UsersIdResponse
- Get2UsersIdTimelinesReverseChronologicalResponse
- Get2UsersIdTweetsResponse
- Get2UsersMeResponse
- Get2UsersResponse
- HashtagEntity
- HashtagFields
- InvalidRequestProblem
- InvalidRequestProblemAllOf
- InvalidRequestProblemAllOfErrors
- InvalidRuleProblem
- ListAddUserRequest
- ListCreateRequest
- ListCreateResponse
- ListCreateResponseData
- ListDeleteResponse
- ListDeleteResponseData
- ListFollowedRequest
- ListFollowedResponse
- ListFollowedResponseData
- ListMutateResponse
- ListMutateResponseData
- ListPinnedRequest
- ListPinnedResponse
- ListPinnedResponseData
- ListUnpinResponse
- ListUpdateRequest
- ListUpdateResponse
- ListUpdateResponseData
- Media
- MentionEntity
- MentionFields
- ModelList
- MuteUserMutationResponse
- MuteUserMutationResponseData
- MuteUserRequest
- NonCompliantRulesProblem
- OperationalDisconnectProblem
- OperationalDisconnectProblemAllOf
- Photo
- PhotoAllOf
- Place
- PlaceType
- Point
- Poll
- PollOption
- Problem
- ProblemErrors
- ProblemOrError
- ReplySettings
- ReportUsersRequest
- ReportUsersResponse
- ReportUsersResponseData
- ResourceNotFoundProblem
- ResourceNotFoundProblemAllOf
- ResourceUnauthorizedProblem
- ResourceUnauthorizedProblemAllOf
- ResourceUnavailableProblem
- ResourceUnavailableProblemAllOf
- Rule
- RuleNoId
- RulesCapProblem
- RulesLookupResponse
- RulesRequestSummary
- RulesRequestSummaryOneOf
- RulesRequestSummaryOneOf1
- RulesResponseMetadata
- SearchCount
- Space
- SpaceTopicsInner
- StreamingTweetResponse
- Topic
- Tweet
- TweetAttachments
- TweetCreateRequest
- TweetCreateRequestGeo
- TweetCreateRequestMedia
- TweetCreateRequestPoll
- TweetCreateRequestReply
- TweetCreateResponse
- TweetCreateResponseData
- TweetDeleteResponse
- TweetDeleteResponseData
- TweetGeo
- TweetHideRequest
- TweetHideResponse
- TweetHideResponseData
- TweetNonPublicMetrics
- TweetOrganicMetrics
- TweetPromotedMetrics
- TweetPublicMetrics
- TweetReferencedTweetsInner
- TweetWithheld
- UnsupportedAuthenticationProblem
- UrlEntity
- UrlFields
- UrlImage
- UsageCapExceededProblem
- UsageCapExceededProblemAllOf
- User
- UserEntities
- UserEntitiesUrl
- UserPublicMetrics
- UserWithheld
- UsersFollowingCreateRequest
- UsersFollowingCreateResponse
- UsersFollowingCreateResponseData
- UsersFollowingDeleteResponse
- UsersLikesCreateRequest
- UsersLikesCreateResponse
- UsersLikesCreateResponseData
- UsersLikesDeleteResponse
- UsersRetweetsCreateRequest
- UsersRetweetsCreateResponse
- UsersRetweetsCreateResponseData
- UsersRetweetsDeleteResponse
- Variant
- Video
- VideoAllOf
- VideoAllOfNonPublicMetrics
- VideoAllOfOrganicMetrics
- VideoAllOfPromotedMetrics
- VideoAllOfPublicMetrics
Authorization
BearerToken
- Type: Bearer authentication
OAuth2UserToken
- Type:
OAuth
- Flow:
accessCode
- Authorization URL:
https://api.twitter.com/2/oauth2/authorize
- Scopes:
- block.read: Accounts you’ve blocked.
- block.write: Block and unblock accounts for you.
- bookmark.read: Allows an app to read bookmarked Tweets
- bookmark.write: Allows an app to create and delete bookmarks
- follows.read: People who follow you and people who you follow.
- follows.write: Follow and unfollow people for you.
- like.read: Tweets you’ve liked and likes you can view.
- like.write: Like and un-like Tweets for you.
- list.read: Lists, list members, and list followers of lists you’ve created or are a member of, including private lists.
- list.write: Create and manage Lists for you.
- mute.read: Accounts you’ve muted.
- mute.write: Mute and unmute accounts for you.
- space.read: Access all of the Spaces you can see.
- tweet.moderate.write: Hide and unhide replies to your Tweets.
- tweet.read: All the Tweets you can see, including Tweets from protected accounts.
- tweet.write: Tweet and retweet for you.
- users.read: Any account you can see, including protected accounts. Any account you can see, including protected accounts.
UserToken
Tests
To run the tests, use:
composer install vendor/bin/phpunit
Author
About this package
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
2.45
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen