samlitowitz/twitter-php-openapi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samlitowitz/twitter-php-openapi

Composer 安装命令:

composer require samlitowitz/twitter-php-openapi

包简介

Twitter API v2 available endpoints

README 文档

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

Class Method HTTP request Description
BookmarksApi getUsersIdBookmarks GET /2/users/{id}/bookmarks Bookmarks by User
BookmarksApi postUsersIdBookmarks POST /2/users/{id}/bookmarks Add Tweet to Bookmarks
BookmarksApi usersIdBookmarksDelete DELETE /2/users/{id}/bookmarks/{tweet_id} Remove a bookmarked Tweet
ComplianceApi createBatchComplianceJob POST /2/compliance/jobs Create compliance job
ComplianceApi getBatchComplianceJob GET /2/compliance/jobs/{id} Get Compliance Job
ComplianceApi listBatchComplianceJobs GET /2/compliance/jobs List Compliance Jobs
GeneralApi getOpenApiSpec GET /2/openapi.json Returns the OpenAPI Specification document.
ListsApi getUserListMemberships GET /2/users/{id}/list_memberships Get a User's List Memberships
ListsApi listAddMember POST /2/lists/{id}/members Add a List member
ListsApi listIdCreate POST /2/lists Create List
ListsApi listIdDelete DELETE /2/lists/{id} Delete List
ListsApi listIdGet GET /2/lists/{id} List lookup by List ID.
ListsApi listIdUpdate PUT /2/lists/{id} Update List.
ListsApi listRemoveMember DELETE /2/lists/{id}/members/{user_id} Remove a List member
ListsApi listUserFollow POST /2/users/{id}/followed_lists Follow a List
ListsApi listUserOwnedLists GET /2/users/{id}/owned_lists Get a User's Owned Lists.
ListsApi listUserPin POST /2/users/{id}/pinned_lists Pin a List
ListsApi listUserPinnedLists GET /2/users/{id}/pinned_lists Get a User's Pinned Lists
ListsApi listUserUnfollow DELETE /2/users/{id}/followed_lists/{list_id} Unfollow a List
ListsApi listUserUnpin DELETE /2/users/{id}/pinned_lists/{list_id} Unpin a List
ListsApi userFollowedLists GET /2/users/{id}/followed_lists Get User's Followed Lists
SpacesApi findSpaceById GET /2/spaces/{id} Space lookup by Space ID
SpacesApi findSpacesByCreatorIds GET /2/spaces/by/creator_ids Space lookup by their creators
SpacesApi findSpacesByIds GET /2/spaces Space lookup up Space IDs
SpacesApi searchSpaces GET /2/spaces/search Search for Spaces
SpacesApi spaceBuyers GET /2/spaces/{id}/buyers Retrieve the list of Users who purchased a ticket to the given space
SpacesApi spaceTweets GET /2/spaces/{id}/tweets Retrieve Tweets from a Space.
TweetsApi addOrDeleteRules POST /2/tweets/search/stream/rules Add/Delete rules
TweetsApi createTweet POST /2/tweets Creation of a Tweet
TweetsApi deleteTweetById DELETE /2/tweets/{id} Tweet delete by Tweet ID
TweetsApi findTweetById GET /2/tweets/{id} Tweet lookup by Tweet ID
TweetsApi findTweetsById GET /2/tweets Tweet lookup by Tweet IDs
TweetsApi findTweetsThatQuoteATweet GET /2/tweets/{id}/quote_tweets Retrieve Tweets that quote a Tweet.
TweetsApi getRules GET /2/tweets/search/stream/rules Rules lookup
TweetsApi hideReplyById PUT /2/tweets/{tweet_id}/hidden Hide replies
TweetsApi listsIdTweets GET /2/lists/{id}/tweets List Tweets timeline by List ID.
TweetsApi sampleStream GET /2/tweets/sample/stream Sample stream
TweetsApi searchStream GET /2/tweets/search/stream Filtered stream
TweetsApi spaceBuyers GET /2/spaces/{id}/buyers Retrieve the list of Users who purchased a ticket to the given space
TweetsApi spaceTweets GET /2/spaces/{id}/tweets Retrieve Tweets from a Space.
TweetsApi tweetCountsFullArchiveSearch GET /2/tweets/counts/all Full archive search counts
TweetsApi tweetCountsRecentSearch GET /2/tweets/counts/recent Recent search counts
TweetsApi tweetsFullarchiveSearch GET /2/tweets/search/all Full-archive search
TweetsApi tweetsRecentSearch GET /2/tweets/search/recent Recent search
TweetsApi usersIdLike POST /2/users/{id}/likes Causes the User (in the path) to like the specified Tweet
TweetsApi usersIdLikedTweets GET /2/users/{id}/liked_tweets Returns Tweet objects liked by the provided User ID
TweetsApi usersIdMentions GET /2/users/{id}/mentions User mention timeline by User ID
TweetsApi usersIdRetweets POST /2/users/{id}/retweets Causes the User (in the path) to retweet the specified Tweet.
TweetsApi usersIdTimeline GET /2/users/{id}/timelines/reverse_chronological User home timeline by User ID
TweetsApi usersIdTweets GET /2/users/{id}/tweets User Tweets timeline by User ID
TweetsApi usersIdUnlike DELETE /2/users/{id}/likes/{tweet_id} Causes the User (in the path) to unlike the specified Tweet
TweetsApi usersIdUnretweets DELETE /2/users/{id}/retweets/{source_tweet_id} Causes the User (in the path) to unretweet the specified Tweet
UsersApi findMyUser GET /2/users/me User lookup me
UsersApi findUserById GET /2/users/{id} User lookup by ID
UsersApi findUserByUsername GET /2/users/by/username/{username} User lookup by username
UsersApi findUsersById GET /2/users User lookup by IDs
UsersApi findUsersByUsername GET /2/users/by User lookup by usernames
UsersApi listGetFollowers GET /2/lists/{id}/followers Returns User objects that follow a List by the provided List ID
UsersApi listGetMembers GET /2/lists/{id}/members Returns User objects that are members of a List by the provided List ID.
UsersApi tweetsIdLikingUsers GET /2/tweets/{id}/liking_users Returns User objects that have liked the provided Tweet ID
UsersApi tweetsIdRetweetingUsers GET /2/tweets/{id}/retweeted_by Returns User objects that have retweeted the provided Tweet ID
UsersApi usersIdBlock POST /2/users/{id}/blocking Block User by User ID
UsersApi usersIdBlocking GET /2/users/{id}/blocking Returns User objects that are blocked by provided User ID
UsersApi usersIdFollow POST /2/users/{id}/following Follow User
UsersApi usersIdFollowers GET /2/users/{id}/followers Returns User objects that follow a List by the provided User ID
UsersApi usersIdFollowing GET /2/users/{id}/following Following by User ID
UsersApi usersIdMute POST /2/users/{id}/muting Mute User by User ID.
UsersApi usersIdMuting GET /2/users/{id}/muting Returns User objects that are muted by the provided User ID
UsersApi usersIdUnblock DELETE /2/users/{source_user_id}/blocking/{target_user_id} Unblock User by User ID
UsersApi usersIdUnfollow DELETE /2/users/{source_user_id}/following/{target_user_id} Unfollow User
UsersApi usersIdUnmute DELETE /2/users/{source_user_id}/muting/{target_user_id} Unmute User by User ID

Models

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

samlitowitz/twitter-php-openapi 适用场景与选型建议

samlitowitz/twitter-php-openapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「openapi」 「openapitools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 samlitowitz/twitter-php-openapi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 samlitowitz/twitter-php-openapi 我们能提供哪些服务?
定制开发 / 二次开发

基于 samlitowitz/twitter-php-openapi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: unlicense
  • 更新时间: 2022-06-11