Guest User

Untitled

a guest
Jan 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # sinatragplus.rb
  2. require 'sinatra'
  3. require 'google_plus'
  4.  
  5. error do
  6. erb :'500'
  7. end
  8.  
  9. #class
  10. class GPlus
  11. def initialize(apikey, gid)
  12. @apikey = apikey
  13. @gid = gid
  14. get_info
  15. end
  16. attr_reader :row0, :row1, :row2
  17. private
  18. #Get info about specific G+ ID
  19. def get_info
  20. # GooglePlus.api_key = 'Your API Key'
  21. begin
  22. GooglePlus.api_key = @apikey
  23. person = GooglePlus::Person.get(@gid.to_i)
  24. @row0 = person.display_name
  25. @row1 = person.tagline
  26. @row2 = person.url
  27. rescue Exception => msg
  28. # display the system generated error message
  29. puts msg
  30. end
  31. end
  32. end
  33.  
  34. get '/' do
  35. erb :index
  36. end
  37.  
  38. # Display Google+ details
  39. post '/show' do
  40. @gplus = GPlus.new(params[:apikey], params[:gid])
  41. erb :show
  42. end
Add Comment
Please, Sign In to add comment