Mastodon
  • 什么是 Mastodon?
  • 使用 Mastodon
    • 注册帐户
    • 设置你的个人资料
    • 在你的账户发布内容
    • 使用网络功能
    • 处理不想看到的内容
    • 推广你和他人
    • 进行偏好设置
    • 更多设置
    • 在站点外使用 Mastodon
    • 迁移或离开账户
    • 运行你自己的站点
  • 运营 Mastodon
    • 准备你的服务器
    • 从源代码安装
    • 配置你的环境
    • 安装可选功能
      • 对象存储
      • 洋葱服务
      • 验证码
      • 单点登录
    • 配置全文搜索
    • 设置你的新实例
    • 使用管理 CLI
    • 升级到新版本
    • 备份你的服务器
    • 迁移到新机器
    • 扩大你的站点规模
    • 审核操作
    • 故障排除
      • 数据库索引损坏
    • 用户组
  • 开发 Mastodon 应用
    • API 入门指南
    • 使用公开数据
    • 获取客户端应用访问权限
    • 使用帐户登录
    • 库与实现
  • 向 Mastodon 项目做贡献
    • 技术概览
    • 设置开发环境
    • 代码结构
    • 路由
    • 漏洞赏金与责任披露
  • 遵循的标准
    • ActivityPub
    • WebFinger
    • 安全性
    • Microformats
    • OAuth
    • Bearcaps
  • REST API
    • Datetime 格式
    • 指南与最佳实践
    • OAuth 令牌
    • OAuth 作用域
    • 速率限制
  • API 方法
    • apps
      • oauth
      • emails
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • followed_tags
      • suggestions
      • tags
    • profile
    • statuses
      • media
      • polls
      • scheduled_statuses
    • timelines
      • conversations
      • lists
      • markers
      • streaming
    • grouped notifications
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
      • announcements
    • admin
      • accounts
      • canonical_email_blocks
      • dimensions
      • domain_allows
      • domain_blocks
      • email_domain_blocks
      • ip_blocks
      • measures
      • reports
      • retention
      • trends
    • proofs
    • oembed
  • API 实体
    • Account
    • AccountWarning
    • Admin::Account
    • Admin::CanonicalEmailBlock
    • Admin::Cohort
    • Admin::Dimension
    • Admin::DomainAllow
    • Admin::DomainBlock
    • Admin::EmailDomainBlock
    • Admin::Ip
    • Admin::IpBlock
    • Admin::Measure
    • Admin::Report
    • Announcement
    • Appeal
    • Application
    • Context
    • Conversation
    • CustomEmoji
    • DomainBlock
    • Error
    • ExtendedDescription
    • FamiliarFollowers
    • FeaturedTag
    • Filter
    • FilterKeyword
    • FilterResult
    • FilterStatus
    • IdentityProof
    • Instance
    • List
    • Marker
    • MediaAttachment
    • Notification
    • NotificationPolicy
    • NotificationRequest
    • Poll
    • Preferences
    • PreviewCard
    • PreviewCardAuthor
    • PrivacyPolicy
    • Reaction
    • Relationship
    • RelationshipSeveranceEvent
    • Report
    • Role
    • Rule
    • ScheduledStatus
    • Search
    • Status
    • StatusEdit
    • StatusSource
    • Suggestion
    • Tag
    • TermsOfService
    • Token
    • Translation
    • V1::Filter
    • V1::Instance
    • V1::NotificationPolicy
    • WebPushSubscription

polls API 方法

查看和投票给附加到嘟文的投票。要发现投票 ID,你需要首先 GET 一个嘟文,然后检查 `poll` 属性。

    • 查看投票
    • 投票
    • 另请参考

查看投票

GET /api/v1/polls/:id HTTP/1.1

查看附加到嘟文的投票。

返回: Poll
OAuth: 若上级嘟文是公开的,则为公开。若上级嘟文是私有的,则为用户令牌 + read:statuses。
版本历史:
2.8.0 - 添加

请求

路径参数
:id
必需 字符串。数据库中投票的 ID。
标头
Authorization
提供此标头,并使用 Bearer <user_token> 以获得对该 API 方法的访问授权。

响应

200: OK
{
  "id": "34830",
  "expires_at": "2019-12-05T04:05:08.302Z",
  "expired": true,
  "multiple": false,
  "votes_count": 10,
  "voters_count": null,
  "voted": true,
  "own_votes": [
    1
  ],
  "options": [
    {
      "title": "accept",
      "votes_count": 6
    },
    {
      "title": "deny",
      "votes_count": 4
    }
  ],
  "emojis": []
}
404: Not found

投票不存在,或投票的上级嘟文是私有的

{
  "error": "Record not found"
}

投票

POST /api/v1/polls/:id/votes HTTP/1.1

投票给附加到嘟文的投票。

返回: Poll
OAuth: 用户令牌 + write:statuses
版本历史:
2.8.0 - 添加

请求

路径参数
:id
必需 字符串。数据库中投票的 ID。
标头
Authorization
必需 提供此标头,并使用 Bearer <user_token> 以获得对该 API 方法的访问授权。
表单数据参数
choices[]
必需 整数数组。将你自己的投票作为每个选项的索引提供(从 0 开始)。

响应

200: OK

已成功进行投票

{
  "id": "34873",
  "expires_at": "2019-12-05T11:16:17.426Z",
  "expired": false,
  "multiple": true,
  "votes_count": 5,
  "voters_count": null,
  "voted": true,
  "own_votes": [
    0,
    2,
    4,
    9,
    6
  ],
  "options": [
    {
      "title": "option 0",
      "votes_count": 1
    },
    {
      "title": "option 1",
      "votes_count": 0
    },
    {
      "title": "option 2",
      "votes_count": 1
    },
    {
      "title": "option 3",
      "votes_count": 0
    },
    {
      "title": "option 4",
      "votes_count": 1
    },
    {
      "title": "option 5",
      "votes_count": 0
    },
    {
      "title": "option 6",
      "votes_count": 1
    },
    {
      "title": "option 7",
      "votes_count": 0
    },
    {
      "title": "option 8",
      "votes_count": 0
    },
    {
      "title": "option 9",
      "votes_count": 1
    }
  ],
  "emojis": []
}
401: Unauthorized

无效或缺少授权标头。

{
  "error": "The access token is invalid"
}
404: Not found

投票不存在,或投票的上级嘟文是私有的

{
  "error": "Record not found"
}
422: Unprocessable entity

投票已过期

{
  "error": "Validation failed: The poll has already ended"
}

或者,你已经进行过投票

{
  "error": "Validation failed: You have already voted on this poll"
}

另请参考

POST /api/v1/statuses (poll parameter)
app/controllers/api/v1/polls_controller.rb
app/controllers/api/v1/polls/votes_controller.rb

翻译状态: 本文是英文页面 polls API methods 的翻译,最后翻译时间:2025-04-21,点击这里可以查看翻译后页面的改动。

最后更新于 April 21, 2025 · 改进此页面
也可在此找到: English

赞助商

Dotcom-Monitor LoadView Stephen Tures Swayable SponsorMotion

加入Mastodon · 博客 ·

查看源代码 · CC BY-SA 4.0 · 版权信息