如何在 ruby 中使用 redditkit 访问 reddit post?
How to access a reddit post using redditkit in ruby?
我有一个 reddit post link 在这里:
我希望通过 redditkit API 访问此 post 的数据。
我已经尝试了无数次,文档对我来说意义不大。有人可以帮助展示如何通过 ruby 控制台执行此操作吗?或者甚至在 rails 中实现它也会非常有帮助!
看看 #comment method on the gem, it takes a comment_full_name
and performs a GET
to api/info.json
with that parameter as an id
(seen by viewing the source for that method). If we look at the reddit api for api/info the id
parameter is a full name
for the object with a link 是什么 full name
。
在link之后,评论的全名是
Fullnames start with the type prefix for the object's type, followed by the thing's unique ID in base 36.
和
type prefixes
t1_ Comment
所以现在我们知道 comment_full_name
应该是 t1_#{comment's unique id}
,看起来是 6m5k0o
。在这里,我不确定这是否已经是 base36,或者他们是否希望您在传递之前将其转换为 base36。没有看到你所做的一切,我会说
client = RedditKit::Client.new 'username', 'password'
client.comment("t1_6m5k0o")
如果这不起作用
client.comment("t1_#{'6m5k0o' base36 encoded}")
对于这样的问题,很高兴看到您的一些代码以及您 tried/results 他们提供的内容。就我所知,您已经尝试过此方法,但它对您不起作用是有原因的。
我会为您测试一下,但我没有用于 gem 登录的 reddit 帐户,这只是我浏览文档的猜测。
我有一个 reddit post link 在这里:
我希望通过 redditkit API 访问此 post 的数据。
我已经尝试了无数次,文档对我来说意义不大。有人可以帮助展示如何通过 ruby 控制台执行此操作吗?或者甚至在 rails 中实现它也会非常有帮助!
看看 #comment method on the gem, it takes a comment_full_name
and performs a GET
to api/info.json
with that parameter as an id
(seen by viewing the source for that method). If we look at the reddit api for api/info the id
parameter is a full name
for the object with a link 是什么 full name
。
在link之后,评论的全名是
Fullnames start with the type prefix for the object's type, followed by the thing's unique ID in base 36.
和
type prefixes
t1_ Comment
所以现在我们知道 comment_full_name
应该是 t1_#{comment's unique id}
,看起来是 6m5k0o
。在这里,我不确定这是否已经是 base36,或者他们是否希望您在传递之前将其转换为 base36。没有看到你所做的一切,我会说
client = RedditKit::Client.new 'username', 'password'
client.comment("t1_6m5k0o")
如果这不起作用
client.comment("t1_#{'6m5k0o' base36 encoded}")
对于这样的问题,很高兴看到您的一些代码以及您 tried/results 他们提供的内容。就我所知,您已经尝试过此方法,但它对您不起作用是有原因的。
我会为您测试一下,但我没有用于 gem 登录的 reddit 帐户,这只是我浏览文档的猜测。