Class: Socialshare::Facebook

Inherits:
Object
  • Object
show all
Defined in:
lib/socialshare/facebook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Facebook

Returns a new instance of Facebook.



7
8
9
10
# File 'lib/socialshare/facebook.rb', line 7

def initialize(options = {})
  @fb_token = options[:fb_token]
  @fb_user = get_fb_user(options[:fb_token])
end

Instance Attribute Details

#fb_tokenObject

Returns the value of attribute fb_token.



5
6
7
# File 'lib/socialshare/facebook.rb', line 5

def fb_token
  @fb_token
end

#fb_userObject

Returns the value of attribute fb_user.



5
6
7
# File 'lib/socialshare/facebook.rb', line 5

def fb_user
  @fb_user
end

Instance Method Details

#get_facebook_connectionsObject



27
28
29
30
31
32
33
# File 'lib/socialshare/facebook.rb', line 27

def get_facebook_connections
  begin
    self.fb_user.get_connections("me", "friends")
  rescue Exception => e
    return e
  end
end

#get_facebook_profileObject



19
20
21
22
23
24
25
# File 'lib/socialshare/facebook.rb', line 19

def get_facebook_profile
  begin
    profile = self.fb_user.get_object("me")
  rescue Exception => e
    return e
  end
end

#post(text) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/socialshare/facebook.rb', line 11

def post(text)
  begin
    self.fb_user.put_wall_post(text)
  rescue Exception => e
    return e
  end
end

#share_picture(file_path) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/socialshare/facebook.rb', line 35

def share_picture(file_path)
  begin
    self.fb_user.put_picture(File.open(file_path))
  rescue Exception => e
    return e
  end
end

#share_video(file_path) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/socialshare/facebook.rb', line 43

def share_video(file_path)
  begin
    self.fb_user.put_video(File.open(file_path))
  rescue Exception => e
    return e
  end
end