gpt4 book ai didi

ruby-on-rails - 从 Page Feed 获取大图像?使用 Koala Gem & Rails 3.2

转载 作者:行者123 更新时间:2023-12-01 08:29:56 26 4
gpt4 key购买 nike

有人知道如何从 Page Feed 中提取不同尺寸的图片吗?

我尝试使用适合 friend 和头像的类型哈希。

@page-feed = @graph.get_connections("somepage", "feed", {"type"=> "large"})

但由于某种原因,我总是为所有帖子获得相同的图片尺寸。

谢谢!

最佳答案

在此处阅读代码:https://github.com/arsduo/koala/blob/81e66f459df840d9d5e122c0d498e2fb9d146655/lib/koala/api/graph_api.rb (第 178 行,def get_picture)您可以看到该方法接受选项哈希:
gem 来源:

# Fetches a photo.# (Facebook returns the src of the photo as a response header; this method parses that properly,# unlike using get_connections("photo").)## @param options options for Facebook (see #get_object).#                        To get a different size photo, pass :type => size (small, normal, large, square).# @param block (see Koala::Facebook::API#api)## @note to delete photos or videos, use delete_object(id)## @return the URL to the imagedef get_picture(object, args = {}, options = {}, &block)  # Gets a picture object, returning the URL (which Facebook sends as a header)  resolved_result = graph_call("#{object}/picture", args, "get", options.merge(:http_component => :headers)) do |result|    result ? result["Location"] : nil  end  block ? block.call(resolved_result) : resolved_resultend

So you can call it like .get_picture(id, type: :large). Like this:

graph = Koala::Facebook::API.new(token)
profile = graph.get_object('me')
graph.get_picture(profile['id'], type: :large)

关于ruby-on-rails - 从 Page Feed 获取大图像?使用 Koala Gem & Rails 3.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21514106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com