Class: BizRatr::FacebookConnector
Instance Method Summary
collapse
Methods inherited from Connector
#initialize
Instance Method Details
#get_url_likes(url) ⇒ Object
54
55
56
|
# File 'lib/bizratr/connector.rb', line 54
def get_url_likes(url)
@client.fql_query("SELECT share_count, like_count, comment_count, click_count FROM link_stat WHERE url='#{url}'")
end
|
#make_business(item) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/bizratr/connector.rb', line 39
def make_business(item)
b = Business.new(@uberclient, item['location']['latitude'], item['location']['longitude'], item['name'])
b.add_id(:facebook, item['id'])
b.city = item['location']['city']
b.country = item['location']['country']
b.phone = item['phone'] unless item['phone'] == "nope"
b.zip = item['location']['zip']
b.website = item['website'].split(' ').first
b.address = item['location']['street']
b.add_categories(:facebook, [item['category']])
b.add_checkins(:facebook, item['checkins'] + item['were_here_count'])
b.add_likes(:facebook, item['likes'])
b
end
|
#make_client(config) ⇒ Object
27
28
29
30
|
# File 'lib/bizratr/connector.rb', line 27
def make_client(config)
oauth = Koala::Facebook::OAuth.new(config[:key], config[:secret])
Koala::Facebook::API.new(oauth.get_app_access_token)
end
|
#search_location(location, query) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/bizratr/connector.rb', line 32
def search_location(location, query)
results = @client.search(query, { :type => 'place', :center => location.join(','), :distance => 1000 })
results.map { |item|
make_business(@client.get_object(item['id']))
}
end
|