Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Provide a function to parse the response of post_tweet for easy creation of threads. #452

Closed
llrs opened this issue Oct 20, 2020 · 3 comments

Comments

@llrs
Copy link
Collaborator

llrs commented Oct 20, 2020

Problem

Looking at the examples of post_tweet, I see that if the first initial tweet is successful it will report the id.

Expected behavior

I think it would be useful to provide a simple function to extract it so that the creation of threads wouldn't require a call to the Twitter API for each reply:

Reproduce the problem

# From post_tweet
# example of replying within a thread
## first post
r <- post_tweet(status="first in a thread")
# Simple function (httr is already a dependency)
id_post <- function(x){httr::content(x)$id_str}
reply_id <- id_post(r)
## post reply
post_tweet("second in the thread",
  in_reply_to_status_id = reply_id)

This approach substitute the following lines from the example:

## lookup status_id
my_timeline <- get_timeline(rtweet:::home_user())

## ID for reply
reply_id <- my_timeline$status_id[1]

rtweet version

## copy/paste output
packageVersion("rtweet")
0.7.0

Session info

## copy/paste output
sessionInfo()

Token

## copy/paste output
rtweet::get_token()
This was referenced Feb 15, 2021
@hadley
Copy link
Collaborator

hadley commented Feb 27, 2021

Probably all the post functions that create something should return the ID of the created object

@hadley
Copy link
Collaborator

hadley commented Mar 31, 2021

I think ideally they'd return some very lightweight S3 class with a print method, so the individual methods would no longer have to use message().

@llrs
Copy link
Collaborator Author

llrs commented Dec 9, 2022

Closing as currently in devel there is a class and S3 method for printing and recovering the id of the tweet posted

@llrs llrs closed this as completed Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants