Guest User

Untitled

a guest
Jan 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. class FoursquareController < ApplicationController
  2. @@foursquare = Foursquare::Base.new(
  3. API_KEYS['foursquare_id'],
  4. API_KEYS['foursquare_secret']
  5. )
  6.  
  7. def foursquare
  8. end
  9.  
  10. def authorize
  11. redirect_to @@foursquare.authorize_url(foursquare_link_url)
  12. end
  13.  
  14. def checkin
  15. checkin = JSON.decode(params[:checkin])
  16. end
  17.  
  18. def link
  19. if params[:code]
  20. access_token = @@foursquare.access_token(params[:code], foursquare_link_url)
  21. current_user[:foursquare_access_token] = access_token
  22. if current_user.save
  23. current_user.import_check_ins
  24. flash[:notice] = "User successfully linked with foursquare"
  25. else
  26. flash[:notice] = "Error linking foursquare with user #{current_user.name}"
  27. end
  28. redirect_to root_url
  29. else
  30. flash[:notice] = "You did not give us permission to link with foursquare!"
  31. render 'foursquare'
  32. end
  33. end
  34.  
  35. end
Add Comment
Please, Sign In to add comment