如何使用Instagram API提取Instagram图片标题文本? [英] How to pull Instagram image caption text using the Instagram API?

查看:78
本文介绍了如何使用Instagram API提取Instagram图片标题文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Instagram api在Ruby on Rails中构建网站.我似乎无法弄清楚如何用任何图像提取字幕文本,而且似乎也没有说明如何在文档中的任何位置进行此操作.可以使用api还是我必须使用其他东西?

I'm using the Instagram api to build a site in Ruby on Rails. I can't seem to figure out how to pull caption text with any of the images, and it doesn't seem to state how to do this anywhere in the documentation. Is it possible using the api or do I have to use something else?

我已附上2个非常简单的代码段,以在下面说明我的问题

I've attached 2 very simple code snippets to illustrate my problem below

Ruby:

class HomeController < ApplicationController
  def index
    def index
        @instagram = Instagram.tag_recent_media("blablabla", {:count => 50})
    end
  end
end

这是HTML:

  <div class = "tagged-images-container-position">
    <% @instagram.each do |instagram| %>
            <%= instagram.caption.text %> <!-- THIS LINE DOESN'T WORK -->
            <%= instagram.user.username %> 
            <%= image_tag(instagram.images.standard_resolution.url, class: "tagged-images") %>
    <% end %>
  </div>

推荐答案

在尝试使用标题文字之前,请尝试检查标题文字是否为null.我发现有时它会弹出为空.

Try checking the caption text for null before going for that text propoerty. I found that sometimes it pops up as null.

这篇关于如何使用Instagram API提取Instagram图片标题文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆