app/controllers/map_controller.rb
# return array of users images...convert to json
return array of users images...convert to json
return array of users images ... convert to json
def usersfeed
	p "****users feed****"*5
	client = Instagram.client(:access_token => session[:access_token])
	user = client.user
	image_container = []
	count = 0
	next_max_id = nil
	while count < user.counts.media do
		if next_max_id != nil
			current_page = client.user_recent_media(user.id, {count: 33, max_id: next_max_id})
		else
			current_page = client.user_recent_media(user.id, {count: 33})
		end
		next_max_id = current_page.pagination.next_max_id
		current_page.each do |image|
			if image["location"]
				if image["location"]["latitude"]
					image_container << {
						url: image.images.standard_resolution.url,
						thumbnail: image.images.thumbnail.url,
						location: image.location,
						tags: image.tags,
						username: image.user.username,
					}
				end
			end
		end
		p "current page count is:"
		count += current_page.count
	end
	p "THIS IS MY JSON RESPONSE"
	p image_container.to_json
	respond_to do |format|
		if image_container
			format.json { render :json => image_container }
			format.html {redirect_to '/'}
		else
			format.html { redirect_to map }
			format.json { render :json => image_container.errors.full_messages, :status => :unprocessable_entity }
		end
	end
end
def usersfeed p "****users feed****" * 5 client = Instagram . client ( :access_token => session [ :access_token ] ) user = client . user image_container = [ ] count = 0 next_max_id = nil while count < user . counts . media do if next_max_id != nil current_page = client . user_recent_media ( user . id , { count : 33 , max_id : next_max_id } ) else current_page = client . user_recent_media ( user . id , { count : 33 } ) end next_max_id = current_page . pagination . next_max_id current_page . each do | image | if image [ "location" ] if image [ "location" ] [ "latitude" ] image_container << { url : image . images . standard_resolution . url , thumbnail : image . images . thumbnail . url , location : image . location , tags : image . tags , username : image . user . username , } end end end p "current page count is:" count += current_page . count end p "THIS IS MY JSON RESPONSE" p image_container . to_json respond_to do | format | if image_container format . json { render :json => image_container } format . html { redirect_to '/' } else format . html { redirect_to map } format . json { render :json => image_container . errors . full_messages , :status => :unprocessable_entity } end end end
return array of users images...convert to json
return array of users images ... convert to json