推文
GET accounts/:account_id/tweets¶
为账号的可完全推广用户(默认)或 user_id
参数中指定的用户检索推文详细信息。此操作可针对账号下的任何可推广用户。
资源 URL¶
https://ads-api.twitter.com/10/accounts/:account_id/tweets
参数¶
名称 | 说明 |
---|---|
account_id 必需 |
所使用账号的标识符。出现在资源路径中,通常是所有广告商 API 请求的必要参数,不包含 GET accounts。指定账号必须与已验证的用户关联。 类型:string 示例: |
tweet_type 必需 |
指定 类型:enum 可能值: |
count 可选 |
指定每个不同请求尝试检索的记录数量。 类型:int 默认值: 200 最小值、最大值: 1 、1000 |
cursor 可选 |
指定光标以获取下一页结果。参阅分页了解更多信息。 类型:string 示例: |
include_mentions_and_replies 可选 |
是否从适用推文中筛选掉提及和回复内容。 类型:boolean 默认值: false 可能值: true 、false |
timeline_type 可选 |
返回零投送推文(即“仅用于推广”的推文)、原始推文还是这两者。 类型:enum 默认值: NULLCAST 可能值: ALL 、NULLCAST 、ORGANIC |
trim_user 可选 |
是否在推文响应中排除用户对象。启用时,将返回的用户对象内容仅包含推文的作者用户 ID。 类型:boolean 默认值: false 可能值: true 、false |
tweet_ids 可选 |
以逗号分隔的标识符列表。最多可提供 200 个 ID。 注意:ID 应与指定内容相符 类型:long 示例: |
user_id 可选 |
指定为推文限定的用户范围。未设置时,默认为账号的 类型:long 示例: |
请求示例¶
GET https://ads-api.twitter.com/10/accounts/18ce54d4x5t/tweets?tweet_ids=1166476031668015104&tweet_type=PUBLISHED&trim_user=true
响应示例¶
{
"request": {
"params": {
"tweet_ids": [
"1166476031668015104"
],
"tweet_type": "PUBLISHED",
"trim_user": true,
"account_id": "18ce54d4x5t"
}
},
"next_cursor": null,
"data": [
{
"coordinates": null,
"retweeted": false,
"source": "<a href="https://ads-api.twitter.com" rel="nofollow">Ads API Internal Test App</a>",
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
"urls": []
},
"display_text_range": [
0,
9
],
"favorite_count": 0,
"in_reply_to_status_id_str": null,
"geo": null,
"id_str": "1166476031668015104",
"scopes": {
"followers": false
},
"in_reply_to_user_id": null,
"truncated": false,
"retweet_count": 0,
"id": 1166476031668015104,
"in_reply_to_status_id": null,
"conversation_settings": "EVERYONE",
"nullcast": true,
"created_at": "Tue Aug 27 22:22:12 +0000 2019",
"place": null,
"scheduled_at": null,
"tweet_type": "PUBLISHED",
"favorited": false,
"full_text": "hello, v6",
"lang": "es",
"contributors": [
2417045708
],
"in_reply_to_screen_name": null,
"in_reply_to_user_id_str": null,
"user": {
"id": 756201191646691328,
"id_str": "756201191646691328"
},
"tweet_id": "1166476031668015104"
}
]
}
POST accounts/:account_id/tweet¶
为账号的可完全推广用户(默认)或 as_user_id
参数中指定的用户创建推文。cast 为空(默认)推文和原始推文创建均受支持。cast 为空的推文不会显示在公开时间线中,并且不会向关注者显示。任一类型均可在广告活动中使用。
如果认证用户不是该账号的 FULL
可推广用户,需向 GET accounts/:account_id/authenticated_user_access 端点提出请求,确定其是否有代表此用户发推的权限。TWEET_COMPOSER
权限表示用户可以使用此端点代表 FULL
可推广用户创建 cast 为空的推文。
使用 upload.twitter.com 端点处理媒体时,为 additional_owners
参数传输的 user_id
值需与向此端点传输的 as_user_id
值相同。
资源 URL¶
https://ads-api.twitter.com/10/accounts/:account_id/tweet
参数¶
名称 | 说明 |
---|---|
account_id 必需 |
所使用账号的标识符。出现在资源路径中,通常是所有广告商 API 请求的必要参数,不包含 GET accounts。指定账号必须与已验证的用户关联。 类型:string 示例: |
as_user_id 必需 |
要代表其发布推文的广告商用户 ID。广告商必须通过 ads.twitter.com,向你的用户名授予访问其广告账号的权限。此权限允许你使用自己用户名(而非广告商的用户名)的 OAuth 令牌调用该 API。 类型:long 示例: |
text 有时为必需 |
状态更新文本。如未指定 类型:string 示例: |
card_uri 可选 |
使用任何卡片响应中的 类型:string 示例: |
conversation_settings 可选 |
选择谁可以回复此推文。提到的任何人都可以随时回复。 注意:此字段不会在 POST 请求响应中返回,但会在发出 GET 请求时返回。 注意:此参数仅适用于广告 API v8 及更高版本。 类型:enum 默认值: EVERYONE 可能值: EVERYONE 、FOLLOWING 、MENTIONED_USERS |
media_keys 可选 |
通过指定以逗号分隔的标识符列表,将媒体关联到推文。最多可包含 4 个图像、1 个动画 GIF 或 1 个视频。 类型:string 示例: |
nullcast 可选 |
是否创建 cast 为空(或“仅推广”)的推文。 注意:仅可针对已认证的用户创建原始推文 ( 类型:boolean 默认值: true 可能值: true 、false |
trim_user 可选 |
是否在推文响应中排除用户对象。启用时,将返回的用户对象内容仅包含推文的作者用户 ID。 类型:boolean 默认值: false 可能值: true 、false |
tweet_mode 可选 |
响应属于兼容模式还是扩展模式。请参见此处,获取其他信息。 类型:string 可能值: |
video_cta 可选 |
视频的 CTA。 类型:enum 可能值: |
video_cta_value 可选 |
视频中相应 CTA 的值。 类型:string 示例: |
video_description 可选 |
出现在视频下方的说明中。最大长度:200 个字符。 类型:string 示例: |
video_title 可选 |
出现在视频下方的标题中。最大长度:70 个字符。 类型:string 示例: |
请求示例¶
POST https://ads-api.twitter.com/10/accounts/18ce54d4x5t/tweet?text=hello, world&as_user_id=756201191646691328&trim_user=true
响应示例¶
{
"data": {
"created_at": "Sat Jun 24 05:08:30 +0000 2017",
"id": 878479925472251906,
"id_str": "878479925472251906",
"text": "hello, world",
"truncated": false,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
"urls": []
},
"source": "<a href='"https://ads-api.twitter.com"' rel='"nofollow"'>Ads API Internal Test App</a>",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
"id": 756201191646691328,
"id_str": "756201191646691328"
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"retweet_count": 0,
"favorite_count": 0,
"favorited": false,
"retweeted": false,
"scopes": {
"followers": false
},
"lang": "en"
},
"request": {
"params": {
"text": "hello, world",
"trim_user": true,
"as_user_id": 756201191646691328,
"account_id": "18ce54d4x5t"
}
}
}