-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.rb
48 lines (35 loc) · 1.02 KB
/
lib.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'fb_secret'
require 'active_record'
require 'net/https'
require 'json'
require 'uri'
############ create sqlite db in memory ################
DB_FILE = "fb_test_users.sqlite"
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => DB_FILE
)
if !File.exists?(DB_FILE)
ActiveRecord::Schema.define do
create_table :users do |table|
table.column :fb_id, :string
table.column :access_token, :string
table.column :login_url, :string
table.column :email, :string
table.column :password, :string
end
end
end
############ active record declarations ################
class User < ActiveRecord::Base
has_many :users
end
############ define methods ################
def get(path)
uri = URI.parse("https://graph.facebook.com"+path)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
return http.request(request).body
end