Skip to content

Commit

Permalink
create instagram search
Browse files Browse the repository at this point in the history
  • Loading branch information
k1row committed Dec 4, 2012
1 parent 0dfab67 commit 30471ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ class SearchController < ApplicationController
#https://api.instagram.com/v1/media/popular?access_token=223375.0a1df61.d452361af51c44efbe72437d0ab64764
#https://api.instagram.com/v1/tags/search?q=food&access_token=223375.0a1df61.d452361af51c44efbe72437d0ab64764

@target_tag = ENV['INSTAGRAM_TARGET_TAG'] || 'car'
@@target_path = "/#{@target_tag}"
@@target_url = "https://api.instagram.com/v1/tags#{@@target_path}/media/recent?access_token="
@@access_token = "223375.0a1df61.d452361af51c44efbe72437d0ab64764"
@@base_url = @@target_url + "#{@@access_token}"

@data = []
@error = false
Expand All @@ -47,21 +43,30 @@ def index
if @i == "search" then
q = params['q']
if q != nil then
@target_tag = q
@target_tag = q
@@target_path = "/#{@target_tag}"
@@target_url = "https://api.instagram.com/v1/tags#{@@target_path}/media/recent?access_token="
@@base_url = @@target_url + "#{@@access_token}"

logger.debug(@target_tag)
create_data
end
end
end
def create_data
logger.debug(@@base_url)
json = parse_json(@@base_url)
#json = p_json(@@base_url)
logger.debug(json.inspect)
#logger.debug(json.inspect)

if json == nil then
return
end
#redirect_to :back unless json['meta']['code'] && json['meta']['code'] == 200

@data = extract_data(json['data'])
logger.debug(@data.inspect)
logger.debug "@@@ result @@@"
#logger.debug(@data.inspect)
#logger.debug "@@@ result @@@"
end
def p_json(url)
#logger.debug "@@@ p_json @@@"
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%#= debug(data) %>
<a href="<%= data['link'] %>"><%= image_tag data['thumbnail'] %></a>
<% end %>
<% elsif @q == 'search' %>
<% elsif @i == 'search' %>
<h2>Nothing ... such a tag's data</h2>
<% end %>
Expand Down

0 comments on commit 30471ae

Please sign in to comment.