forked from jstewart/yammer4r
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverse example to original behavior. Add explanations through commen…
…ts to activate example for TokenClient and new gem features.
- Loading branch information
yann ARMAND
committed
Jun 14, 2012
1 parent
793edf2
commit 732dbe5
Showing
1 changed file
with
25 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
require 'yammer4r' | ||
|
||
config_path = File.dirname(__FILE__) + '/oauth.yml' | ||
# yammer = Yammer::OAuthClient.new(:config => config_path) | ||
yammer = Yammer::TokenClient.new(:token => "d2wBYkJrgspivfpmJgu1VQ") | ||
yammer = Yammer::OAuthClient.new(:config => config_path) | ||
## comment previous line and uncomment next to try Token based client. | ||
# You have to set the token. you can find it in your file oauth.yml or use on given by a 3rd party oauth2 tool | ||
# yammer = Yammer::TokenClient.new(:token => "d2wBYkJrgspivfpmJgu1VQ") | ||
|
||
# Get all messages | ||
# messages = yammer.messages | ||
# puts messages.size | ||
# puts messages.last.body.plain | ||
# puts messages.last.body.parsed | ||
messages = yammer.messages | ||
puts messages.size | ||
puts messages.last.body.plain | ||
puts messages.last.body.parsed | ||
|
||
# Print out all the users | ||
#yammer.users.each do |u| | ||
# puts "#{u.name} - #{u.me?}" | ||
#end | ||
|
||
topic=Yammer::Topic.find_by_name("Yaflow",yammer) | ||
parsed_all = JSON.parse(yammer.raw_request("messages/about_topic/#{topic.id}").body) unless topic.nil? | ||
msg_with_attach = parsed_all["messages"].select{|m| !m["attachments"].empty? } | ||
pages_json = [] | ||
msg_with_attach.each do |m| | ||
m["attachments"].each do |a| | ||
pages_json = pages_json.push(a["real_id"]) if a["real_type"] == "page" | ||
end | ||
yammer.users.each do |u| | ||
puts "#{u.name} - #{u.me?}" | ||
end | ||
|
||
puts pages_json | ||
# a more complex example to find all pages attached to message from a given topic. | ||
# note the usage of raw_request | ||
# | ||
### uncomment following lines to test it ### | ||
#topic=Yammer::Topic.find_by_name("a_topic",yammer) | ||
#parsed_all = JSON.parse(yammer.raw_request("messages/about_topic/#{topic.id}").body) unless topic.nil? | ||
#msg_with_attach = parsed_all["messages"].select{|m| !m["attachments"].empty? } | ||
#pages_json = [] | ||
#msg_with_attach.each do |m| | ||
# m["attachments"].each do |a| | ||
# pages_json = pages_json.push(a["real_id"]) if a["real_type"] == "page" | ||
# end | ||
#end | ||
#puts pages_json | ||
############################################# |