Foursquare API with Rails app?

I've set up authentication with the Foursquare API and my Rails app, and now it's time to add functionality. I am not too proficient with Rails - it is not my first language. I want to allow a merchant to connect with Foursquare (Working) and then direct the merchant to a page where they can see unique visitors to their venue, the number of checkins to the venue, and who the mayor of the venue is. I know what endpoints to use, I'm just not sure how to implement them in rails. (Access Token, etc.)

Thanks!

After Answer

I'm trying to implement Turd Ferguson's answer, but I'm not getting anywhere. I keep getting an error saying the method is undefined. I want to try a simple venue search as soon as the user is authenticated. (Create Action)

Also, I'm using OmniAuth for authentication.

sessions_controller.rb

class SessionsController < ApplicationController

  require 'foursquare'


  def create
    auth_hash = request.env['omniauth.auth']
    venues = Foursquare::search_venues("starbucks")
    render :text => venues
  end

  def failure
  end

  def destroy
    session[:user_id] = nil
    render :text => "Logged out!"
  end

  def callback
      code = params[:code]
      @access_token = foursquare.access_token(code, callback_session_url)
      session[:access_token] = @access_token

      redirect_to examples_path
  end


end

foursquare.rb class Foursquare

  def self.search_venues(text)
    client.search_venues(:ll => '36.142064,-86.816086', :query => text)
  end

  def self.client
    @client ||= Foursquare2::Client.new(:client_id => '0YO3F0JNZIPVKG1DE01MNPB132D4JZ0QYRQSOWTZQKHHOPKB', :client_secret => 'GMBOGWUNL2GIKZZXQPSLE4BMFNGB5LDHQREH2UKUCK1TJ1L0')
  end


end

Answers


Have you looked into using a gem such as foursquare2?

Using the gem you could create a Foursquare class like:

class Foursquare

    def self.search_venues(text)
        client.search_venues(:ll => '36.142064,-86.816086', :query => text)
    end

    def self.client
        @client ||= Foursquare2::Client.new(:client_id => 'your_client_id', :client_secret => 'your_secret')
    end
end

You could then call this anywhere you wanted by doing something like:

venues = Foursquare::search_venues "foobar"

Need Your Help

MonoDroid MVVMCross handle back button pressed on a TabHost

android windows-phone-7 xamarin.ios xamarin.android mvvmcross

I am using the MvvmCross framework to build a cross platform (iOS, Android, WP7) application. I am currently trying to handle the back button pressed on Android from a TabHost Activity. The TabHost

How to make your own mailing services like gmail or yahoo

php localhost database-mail

I am a noob to php and database...But i have an idea to perform mail operations on my own webserver(i.e just by database operations)but i really dont have any idea of how to send mail to external