Module: Orkut::Client::Scraps

Included in:
Orkut::Client
Defined in:
lib/orkut/client/scraps.rb

Instance Method Summary collapse

Instance Method Details

#scrapsObject

get scraps



8
9
10
# File 'lib/orkut/client/scraps.rb', line 8

def scraps
  Orkut::Connect.new.post_json_rpc self, Orkut::RPC::SCRAPS
end

#send_scrap(token, secret, friend_social_id, msg) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/orkut/client/scraps.rb', line 57

def send_scrap(token, secret, friend_social_id, msg)
  
  consumer = initialize_consumer

  token_hash = { :oauth_token => token, :oauth_token_secret => secret }
  access_token = OAuth::AccessToken.from_hash(consumer, token_hash )
  
  data = "
  {
  'method' : 'messages.create',
  'id' : 'myself',
  'params' : 
  {
  'userId' : '#{friend_social_id}',
  'groupId' : '@self',
  'message' : 
  {
  'recipients' : '#{friend_social_id}',
  'body' : '#{msg}', 
  'title' : 'Chip',
  },
  'messageType' : 'public_message'
  }
  }"
  
  result = access_token.post(RPC_ENDPOINT, data, { 'Content-Type' => 'application/json' }).body
  MultiJson.decode(result)
end

#send_scrap_with_captcha(token, secret, friend_social_id, msg, captchaAnswer, captchaValue) ⇒ Object



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
47
48
49
50
51
52
53
54
# File 'lib/orkut/client/scraps.rb', line 12

def send_scrap_with_captcha(token, secret, friend_social_id, msg, captchaAnswer, captchaValue)

  consumer = initialize_consumer

  token_hash = { :oauth_token => token, :oauth_token_secret => secret }
  access_token = OAuth::AccessToken.from_hash(consumer, token_hash )

  data = "
  [
  {
  'method' : 'captcha.answer',
  'id' : 'myself',
  'params' : 
  {
  'userId' : '@me',
  'groupId' : '@self',
  'captchaAnswer' : '#{captchaAnswer}',
  'captchaToken' : '#{captchaValue}'
  }
  }
  ,
  {
  'method' : 'messages.create',
  'id' : 'myself',
  'params' : 
  {
  'userId' : '#{friend_social_id}',
  'groupId' : '@self',
  'message' : 
  {
  'recipients' : '#{friend_social_id}',
  'body' : '#{msg}', 
  'title' : 'teste',
  },
  'messageType' : 'public_message'
  }
  }
  ]
  "
  
  result = access_token.post(RPC_ENDPOINT, data, { 'Content-Type' => 'application/json' }).body
  
end