app/controllers/map_controller.rb
# return array with first 100 geotagged images of users friends...convert to json
return array with first 100 geotagged images of users friends...convert to json
return array with first 100 geotagged images of users friends ... convert to json
def mediafeed 
	puts "****media feed****"*5
	client = Instagram.client(:access_token => session[:access_token])
	user = client.user
	image_container = []
	count = 0
	next_max_id = nil
	while image_container.count < 100 do
		if next_max_id != nil
			current_page = client.user_media_feed({count: 33, max_id: next_max_id})
		else
			current_page = client.user_media_feed({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 mediafeed puts "****media feed****" * 5 client = Instagram . client ( :access_token => session [ :access_token ] ) user = client . user image_container = [ ] count = 0 next_max_id = nil while image_container . count < 100 do if next_max_id != nil current_page = client . user_media_feed ( { count : 33 , max_id : next_max_id } ) else current_page = client . user_media_feed ( { 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 with first 100 geotagged images of users friends...convert to json
return array with first 100 geotagged images of users friends ... convert to json