myspaceid-sdk 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +30 -0
- data/lib/myspace.rb +15 -0
- data/lib/myspace/exceptions.rb +31 -0
- data/lib/myspace/myspace.rb +565 -0
- data/lib/myspace/oauth.rb +62 -0
- data/lib/patches.rb +42 -0
- data/samples/rails/README +83 -0
- data/samples/rails/consumer_key.rb +4 -0
- data/samples/rails/consumer_key.rb-copyme +4 -0
- data/samples/rails/sample/README +256 -0
- data/samples/rails/sample/Rakefile +10 -0
- data/samples/rails/sample/app/controllers/application.rb +15 -0
- data/samples/rails/sample/app/controllers/oauth_controller.rb +68 -0
- data/samples/rails/sample/app/controllers/openid_controller.rb +105 -0
- data/samples/rails/sample/app/controllers/user_controller.rb +96 -0
- data/samples/rails/sample/app/helpers/application_helper.rb +3 -0
- data/samples/rails/sample/app/helpers/oauth_helper.rb +2 -0
- data/samples/rails/sample/app/helpers/openid_helper.rb +2 -0
- data/samples/rails/sample/app/helpers/user_helper.rb +90 -0
- data/samples/rails/sample/app/views/oauth/error.rhtml +8 -0
- data/samples/rails/sample/app/views/oauth/index.rhtml +8 -0
- data/samples/rails/sample/app/views/oauth/profile.rhtml +74 -0
- data/samples/rails/sample/app/views/openid/index.rhtml +125 -0
- data/samples/rails/sample/app/views/user/complete.rhtml +59 -0
- data/samples/rails/sample/app/views/user/index.rhtml +157 -0
- data/samples/rails/sample/config/boot.rb +109 -0
- data/samples/rails/sample/config/database.yml +22 -0
- data/samples/rails/sample/config/environment.rb +75 -0
- data/samples/rails/sample/config/environments/development.rb +17 -0
- data/samples/rails/sample/config/environments/production.rb +24 -0
- data/samples/rails/sample/config/environments/test.rb +22 -0
- data/samples/rails/sample/config/initializers/inflections.rb +10 -0
- data/samples/rails/sample/config/initializers/mime_types.rb +5 -0
- data/samples/rails/sample/config/initializers/new_rails_defaults.rb +17 -0
- data/samples/rails/sample/config/locales/en.yml +5 -0
- data/samples/rails/sample/config/routes.rb +43 -0
- data/samples/rails/sample/db/development.sqlite3 +0 -0
- data/samples/rails/sample/doc/README_FOR_APP +5 -0
- data/samples/rails/sample/public/404.html +30 -0
- data/samples/rails/sample/public/422.html +30 -0
- data/samples/rails/sample/public/500.html +33 -0
- data/samples/rails/sample/public/dispatch.cgi +10 -0
- data/samples/rails/sample/public/dispatch.fcgi +24 -0
- data/samples/rails/sample/public/dispatch.rb +10 -0
- data/samples/rails/sample/public/favicon.ico +0 -0
- data/samples/rails/sample/public/images/8b_Home.jpg +0 -0
- data/samples/rails/sample/public/images/8b_homecomp_200.jpg +0 -0
- data/samples/rails/sample/public/images/8b_profile_page_201.jpg +0 -0
- data/samples/rails/sample/public/images/LArge_150x35_myspaceID.png +0 -0
- data/samples/rails/sample/public/images/MySpaceID-loginwith-156x28.png +0 -0
- data/samples/rails/sample/public/images/appengine_button_noborder.gif +0 -0
- data/samples/rails/sample/public/images/background.png +0 -0
- data/samples/rails/sample/public/images/blue_150_Loginwithmyspaceid.png +0 -0
- data/samples/rails/sample/public/images/blue_150_signupwithmyspaceid.png +0 -0
- data/samples/rails/sample/public/images/blue_90_myspaceid.png +0 -0
- data/samples/rails/sample/public/images/button-background.gif +0 -0
- data/samples/rails/sample/public/images/grey_150_Loginwithmyspaceid.png +0 -0
- data/samples/rails/sample/public/images/grey_180_signupwithmyspaceid.png +0 -0
- data/samples/rails/sample/public/images/grey_90_myspaceid.png +0 -0
- data/samples/rails/sample/public/images/image.gif +0 -0
- data/samples/rails/sample/public/images/keyhole_buttons_only.png +0 -0
- data/samples/rails/sample/public/images/level_icon.png +0 -0
- data/samples/rails/sample/public/images/myspaceid.png +0 -0
- data/samples/rails/sample/public/images/nav_select.png +0 -0
- data/samples/rails/sample/public/images/openid-16x16.gif +0 -0
- data/samples/rails/sample/public/images/openid-icon.png +0 -0
- data/samples/rails/sample/public/images/openid-logo.png +0 -0
- data/samples/rails/sample/public/images/profile_icon.png +0 -0
- data/samples/rails/sample/public/images/profile_pic.png +0 -0
- data/samples/rails/sample/public/images/rails.png +0 -0
- data/samples/rails/sample/public/images/ranking_badge.png +0 -0
- data/samples/rails/sample/public/images/song_play.png +0 -0
- data/samples/rails/sample/public/images/song_sound.png +0 -0
- data/samples/rails/sample/public/images/star_grey.png +0 -0
- data/samples/rails/sample/public/images/star_yellow.png +0 -0
- data/samples/rails/sample/public/index.html +19 -0
- data/samples/rails/sample/public/index.html.orig +274 -0
- data/samples/rails/sample/public/javascripts/application.js +2 -0
- data/samples/rails/sample/public/javascripts/controls.js +963 -0
- data/samples/rails/sample/public/javascripts/dragdrop.js +973 -0
- data/samples/rails/sample/public/javascripts/effects.js +1128 -0
- data/samples/rails/sample/public/javascripts/myspaceid.rev.0.js +103 -0
- data/samples/rails/sample/public/javascripts/prototype.js +4320 -0
- data/samples/rails/sample/public/robots.txt +5 -0
- data/samples/rails/sample/public/stylesheets/base.css +46 -0
- data/samples/rails/sample/public/stylesheets/main.css +65 -0
- data/samples/rails/sample/public/stylesheets/openid.css +119 -0
- data/samples/rails/sample/script/about +4 -0
- data/samples/rails/sample/script/console +3 -0
- data/samples/rails/sample/script/dbconsole +3 -0
- data/samples/rails/sample/script/destroy +3 -0
- data/samples/rails/sample/script/generate +3 -0
- data/samples/rails/sample/script/performance/benchmarker +3 -0
- data/samples/rails/sample/script/performance/profiler +3 -0
- data/samples/rails/sample/script/performance/request +3 -0
- data/samples/rails/sample/script/plugin +3 -0
- data/samples/rails/sample/script/process/inspector +3 -0
- data/samples/rails/sample/script/process/reaper +3 -0
- data/samples/rails/sample/script/process/spawner +3 -0
- data/samples/rails/sample/script/runner +3 -0
- data/samples/rails/sample/script/server +3 -0
- data/samples/rails/sample/test/functional/oauth_controller_test.rb +8 -0
- data/samples/rails/sample/test/functional/openid_controller_test.rb +8 -0
- data/samples/rails/sample/test/functional/user_controller_test.rb +8 -0
- data/samples/rails/sample/test/performance/browsing_test.rb +9 -0
- data/samples/rails/sample/test/test_helper.rb +38 -0
- data/test/data.rb +8 -0
- data/test/myspace_test.rb +13 -0
- data/test/tc_albums.rb +126 -0
- data/test/tc_friends.rb +96 -0
- data/test/tc_profile.rb +107 -0
- data/test/tc_videos.rb +125 -0
- data/test/test_data.rb +14 -0
- data/test/ts_alltests.rb +7 -0
- metadata +222 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
+
|
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
|
5
|
+
|
|
6
|
+
require 'rake'
|
|
7
|
+
require 'rake/testtask'
|
|
8
|
+
require 'rake/rdoctask'
|
|
9
|
+
|
|
10
|
+
require 'tasks/rails'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
|
3
|
+
|
|
4
|
+
class ApplicationController < ActionController::Base
|
|
5
|
+
helper :all # include all helpers, all the time
|
|
6
|
+
|
|
7
|
+
# See ActionController::RequestForgeryProtection for details
|
|
8
|
+
# Uncomment the :secret if you're not using the cookie session store
|
|
9
|
+
protect_from_forgery # :secret => 'f9d4792ad12b4071f71303295c6c2fd6'
|
|
10
|
+
|
|
11
|
+
# See ActionController::Base for details
|
|
12
|
+
# Uncomment this to filter the contents of submitted sensitive data parameters
|
|
13
|
+
# from your application log (in this case, all fields with names like "password").
|
|
14
|
+
# filter_parameter_logging :password
|
|
15
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'myspace'
|
|
2
|
+
|
|
3
|
+
key_file = File.expand_path(File.join(File.dirname(__FILE__), "/../../../consumer_key.rb"))
|
|
4
|
+
raise "You must create a consumer_key.rb file with your application credentials in it. See #{File.expand_path(File.join(File.dirname(__FILE__), "/../../../../README"))} for more info." unless File.exists?(key_file)
|
|
5
|
+
require key_file
|
|
6
|
+
|
|
7
|
+
class OauthController < ApplicationController
|
|
8
|
+
include ConsumerKey
|
|
9
|
+
|
|
10
|
+
def index
|
|
11
|
+
redirect_to(:action => :profile) if session[:authed_token]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def start_auth
|
|
15
|
+
myspace = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET)
|
|
16
|
+
request_token = myspace.get_request_token
|
|
17
|
+
callback_url = url_for(:action => :callback, :only_path => false)
|
|
18
|
+
auth_url = myspace.get_authorization_url(request_token, callback_url)
|
|
19
|
+
session[:unauthed_token] = {:token => request_token.token, :secret => request_token.secret}
|
|
20
|
+
redirect_to(auth_url)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def callback
|
|
24
|
+
unless session[:unauthed_token]
|
|
25
|
+
flash[:error] = "No un-authed token found in session"
|
|
26
|
+
render(:action => :error)
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
myspace = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET,
|
|
30
|
+
:request_token => session[:unauthed_token][:token],
|
|
31
|
+
:request_token_secret => session[:unauthed_token][:secret])
|
|
32
|
+
myspace.http_logger = logger
|
|
33
|
+
# unless session[:unauthed_token][:token] == params[:oauth_token]
|
|
34
|
+
# p("request_token: #{request_token.token}, returned #{params[:oauth_token]}")
|
|
35
|
+
# flash[:error] = "Something went wrong! Tokens do not match"
|
|
36
|
+
# render(:action => :error)
|
|
37
|
+
# return
|
|
38
|
+
# end
|
|
39
|
+
access_token = myspace.get_access_token
|
|
40
|
+
session[:authed_token] = {:token => access_token.token, :secret => access_token.secret}
|
|
41
|
+
redirect_to(:action => :profile)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def profile
|
|
45
|
+
unless session[:authed_token]
|
|
46
|
+
flash[:error] = "You need an access token in the session!"
|
|
47
|
+
render(:action => :error)
|
|
48
|
+
return
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
access_token = session[:authed_token][:token]
|
|
52
|
+
access_token_secret = session[:authed_token][:secret]
|
|
53
|
+
|
|
54
|
+
logger.info("############################################################")
|
|
55
|
+
logger.info("TOKEN = '#{access_token}' unless const_defined?('TOKEN')")
|
|
56
|
+
logger.info("SECRET = '#{access_token_secret}' unless const_defined?('SECRET')")
|
|
57
|
+
logger.info("############################################################")
|
|
58
|
+
|
|
59
|
+
myspace = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET,
|
|
60
|
+
:access_token => access_token,
|
|
61
|
+
:access_token_secret => access_token_secret)
|
|
62
|
+
myspace.http_logger = logger
|
|
63
|
+
@user_id = myspace.get_userid
|
|
64
|
+
@profile_data = myspace.get_profile(@user_id)
|
|
65
|
+
@friends_data = myspace.get_friends(@user_id)
|
|
66
|
+
session[:authed_token] = nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
require "openid"
|
|
4
|
+
require 'openid/extensions/sreg'
|
|
5
|
+
require 'openid/extensions/pape'
|
|
6
|
+
require 'openid/store/filesystem'
|
|
7
|
+
|
|
8
|
+
require 'myspace'
|
|
9
|
+
|
|
10
|
+
key_file = File.expand_path(File.join(File.dirname(__FILE__), "/../../../consumer_key.rb"))
|
|
11
|
+
raise "You must create a consumer_key.rb file with your application credentials in it. See #{File.expand_path(File.join(File.dirname(__FILE__), "/../../../../README"))} for more info." unless File.exists?(key_file)
|
|
12
|
+
require key_file
|
|
13
|
+
|
|
14
|
+
class OpenidController < ApplicationController
|
|
15
|
+
include ConsumerKey
|
|
16
|
+
|
|
17
|
+
layout nil
|
|
18
|
+
|
|
19
|
+
def index
|
|
20
|
+
# render an openid form
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def start
|
|
24
|
+
begin
|
|
25
|
+
identifier = params[:openid_identifier]
|
|
26
|
+
if identifier.nil?
|
|
27
|
+
flash[:error] = "Enter an OpenID identifier"
|
|
28
|
+
redirect_to :action => 'index'
|
|
29
|
+
return
|
|
30
|
+
end
|
|
31
|
+
oidreq = consumer.begin(identifier)
|
|
32
|
+
rescue OpenID::OpenIDError => e
|
|
33
|
+
flash[:error] = "Discovery failed for #{identifier}: #{e}"
|
|
34
|
+
redirect_to :action => 'index'
|
|
35
|
+
return
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
return_to = url_for :action => 'complete', :only_path => false
|
|
39
|
+
#strip path off for realm
|
|
40
|
+
full_uri = URI::parse(url_for(:action => 'index', :only_path => false))
|
|
41
|
+
full_uri.path = '/'
|
|
42
|
+
realm = full_uri.to_s
|
|
43
|
+
|
|
44
|
+
req = MySpace::OAuth::Request.new(CONSUMER_KEY, nil)
|
|
45
|
+
oidreq.add_extension(req)
|
|
46
|
+
|
|
47
|
+
if oidreq.send_redirect?(realm, return_to, params[:immediate])
|
|
48
|
+
redirect_to oidreq.redirect_url(realm, return_to, params[:immediate])
|
|
49
|
+
else
|
|
50
|
+
render :text => oidreq.html_markup(realm, return_to, params[:immediate], {'id' => 'openid_form'})
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def complete
|
|
55
|
+
# FIXME - url_for some action is not necessarily the current URL.
|
|
56
|
+
current_url = url_for(:action => 'complete', :only_path => false)
|
|
57
|
+
parameters = params.reject{|k,v|request.path_parameters[k]}
|
|
58
|
+
@oidresp = consumer.complete(parameters, current_url)
|
|
59
|
+
case @oidresp.status
|
|
60
|
+
when OpenID::Consumer::FAILURE
|
|
61
|
+
if @oidresp.display_identifier
|
|
62
|
+
flash[:error] = ("Verification of #{@oidresp.display_identifier}"\
|
|
63
|
+
" failed: #{@oidresp.message}")
|
|
64
|
+
else
|
|
65
|
+
flash[:error] = "Verification failed: #{@oidresp.message}"
|
|
66
|
+
end
|
|
67
|
+
when OpenID::Consumer::SUCCESS
|
|
68
|
+
flash[:success] = ("Verification of #{@oidresp.display_identifier}"\
|
|
69
|
+
" succeeded.")
|
|
70
|
+
myspace = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET)
|
|
71
|
+
myspace.http_logger = logger
|
|
72
|
+
oauth_resp = MySpace::OAuth::Response.from_success_response(@oidresp, myspace.consumer)
|
|
73
|
+
token = oauth_resp.authorized_request_token
|
|
74
|
+
if (token)
|
|
75
|
+
access_token = myspace.get_access_token(token)
|
|
76
|
+
logger.info("############################################################")
|
|
77
|
+
logger.info("TOKEN = '#{access_token.token}' unless const_defined?('TOKEN')")
|
|
78
|
+
logger.info("SECRET = '#{access_token.secret}' unless const_defined?('SECRET')")
|
|
79
|
+
logger.info("############################################################")
|
|
80
|
+
@user_id = myspace.get_userid()
|
|
81
|
+
@profile_data = myspace.get_profile(@user_id)
|
|
82
|
+
@friends_data = myspace.get_friends(@user_id)
|
|
83
|
+
@album_data = myspace.get_albums(@user_id)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
when OpenID::Consumer::SETUP_NEEDED
|
|
87
|
+
flash[:alert] = "Immediate request failed - Setup Needed"
|
|
88
|
+
when OpenID::Consumer::CANCEL
|
|
89
|
+
flash[:alert] = "OpenID transaction cancelled."
|
|
90
|
+
else
|
|
91
|
+
end
|
|
92
|
+
render :action => 'index'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
def consumer
|
|
98
|
+
if @consumer.nil?
|
|
99
|
+
dir = Pathname.new(RAILS_ROOT).join('db').join('cstore')
|
|
100
|
+
store = OpenID::Store::Filesystem.new(dir)
|
|
101
|
+
@consumer = OpenID::Consumer.new(session, store)
|
|
102
|
+
end
|
|
103
|
+
return @consumer
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
require "openid"
|
|
4
|
+
require 'openid/extensions/sreg'
|
|
5
|
+
require 'openid/extensions/pape'
|
|
6
|
+
require 'openid/store/filesystem'
|
|
7
|
+
|
|
8
|
+
require 'myspace'
|
|
9
|
+
|
|
10
|
+
key_file = File.expand_path(File.join(File.dirname(__FILE__), "/../../../consumer_key.rb"))
|
|
11
|
+
raise "You must create a consumer_key.rb file with your application credentials in it. See #{File.expand_path(File.join(File.dirname(__FILE__), "/../../../../README"))} for more info." unless File.exists?(key_file)
|
|
12
|
+
require key_file
|
|
13
|
+
|
|
14
|
+
class UserController < ApplicationController
|
|
15
|
+
include ConsumerKey
|
|
16
|
+
|
|
17
|
+
def index
|
|
18
|
+
@is_logged_in = session[:userid] && session[:access_token] && session[:access_token_secret]
|
|
19
|
+
if @is_logged_in
|
|
20
|
+
@userid = session[:userid]
|
|
21
|
+
@ms = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET,
|
|
22
|
+
:access_token => session[:access_token],
|
|
23
|
+
:access_token_secret => session[:access_token_secret])
|
|
24
|
+
@check_user = @userid == @ms.get_userid
|
|
25
|
+
@profile_ext_data = @ms.get_profile(@userid, :detail => :extended)
|
|
26
|
+
@profile_data = @ms.get_profile(@userid)
|
|
27
|
+
@friends_data = @ms.get_friends(@userid)
|
|
28
|
+
begin
|
|
29
|
+
@activities_data = @ms.get_activities(@userid)
|
|
30
|
+
@friends_activities_data = @ms.get_friends_activities(@userid)
|
|
31
|
+
rescue MySpace::PermissionDenied => e
|
|
32
|
+
logger.info("Need to get whitelisted for activities: #{e.inspect}")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def complete
|
|
38
|
+
current_url = url_for(:action => 'complete', :only_path => false)
|
|
39
|
+
parameters = params.reject{|k,v|request.path_parameters[k]}
|
|
40
|
+
@oidresp = consumer.complete(parameters, current_url)
|
|
41
|
+
case @oidresp.status
|
|
42
|
+
when OpenID::Consumer::FAILURE
|
|
43
|
+
if @oidresp.display_identifier
|
|
44
|
+
flash[:error] = ("Verification of #{@oidresp.display_identifier}"\
|
|
45
|
+
" failed: #{@oidresp.message}")
|
|
46
|
+
else
|
|
47
|
+
flash[:error] = "Verification failed: #{@oidresp.message}"
|
|
48
|
+
end
|
|
49
|
+
when OpenID::Consumer::SUCCESS
|
|
50
|
+
flash[:success] = ("Verification of #{@oidresp.display_identifier}"\
|
|
51
|
+
" succeeded.")
|
|
52
|
+
@oid = @oidresp.display_identifier
|
|
53
|
+
@esc_identity = CGI.escape(@oid)
|
|
54
|
+
@cid = @oidresp.endpoint.canonical_id
|
|
55
|
+
|
|
56
|
+
myspace = MySpace::MySpace.new(CONSUMER_KEY, CONSUMER_SECRET)
|
|
57
|
+
myspace.http_logger = logger
|
|
58
|
+
oauth_resp = MySpace::OAuth::Response.from_success_response(@oidresp, myspace.consumer)
|
|
59
|
+
token = oauth_resp.authorized_request_token
|
|
60
|
+
if (token)
|
|
61
|
+
access_token = myspace.get_access_token(token)
|
|
62
|
+
logger.info("############################################################")
|
|
63
|
+
logger.info("TOKEN = '#{access_token.token}' unless const_defined?('TOKEN')")
|
|
64
|
+
logger.info("SECRET = '#{access_token.secret}' unless const_defined?('SECRET')")
|
|
65
|
+
logger.info("############################################################")
|
|
66
|
+
@user_id = myspace.get_userid()
|
|
67
|
+
session[:userid] = @user_id
|
|
68
|
+
session[:access_token] = access_token.token
|
|
69
|
+
session[:access_token_secret] = access_token.secret
|
|
70
|
+
@profile_data = myspace.get_profile(@user_id)
|
|
71
|
+
@friends_data = myspace.get_friends(@user_id)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
when OpenID::Consumer::SETUP_NEEDED
|
|
75
|
+
flash[:alert] = "Immediate request failed - Setup Needed"
|
|
76
|
+
when OpenID::Consumer::CANCEL
|
|
77
|
+
flash[:alert] = "OpenID transaction cancelled."
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def logout
|
|
82
|
+
session[:userid] = nil
|
|
83
|
+
session[:access_token] = nil
|
|
84
|
+
session[:access_token_secret] = nil
|
|
85
|
+
redirect_to :action => :index
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def consumer
|
|
89
|
+
if @consumer.nil?
|
|
90
|
+
dir = Pathname.new(RAILS_ROOT).join('db').join('cstore')
|
|
91
|
+
store = OpenID::Store::Filesystem.new(dir)
|
|
92
|
+
@consumer = OpenID::Consumer.new(session, store)
|
|
93
|
+
end
|
|
94
|
+
return @consumer
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'rexml/xpath'
|
|
2
|
+
|
|
3
|
+
module UserHelper
|
|
4
|
+
def display_name
|
|
5
|
+
@profile_data['basicprofile']['name']
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def profile_age
|
|
9
|
+
@profile_data['age']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def profile_city
|
|
13
|
+
@profile_data['city']
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def profile_pic
|
|
17
|
+
@profile_data['basicprofile']['image'].sub(/\/[sl]_/i, '/m_')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def profile_last_update
|
|
21
|
+
@profile_data['basicprofile']['lastUpdatedDate']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def profile_headline
|
|
25
|
+
@profile_ext_data['headline']
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def profile_about_me
|
|
29
|
+
@profile_data['aboutme']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def profile_to_meet
|
|
33
|
+
remove_html(@profile_ext_data['desiretomeet'])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def profile_name
|
|
37
|
+
remove_html(@profile_data['basicprofile']['name'])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def profile_interests
|
|
41
|
+
remove_html(@profile_ext_data['interests'])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def profile_music
|
|
45
|
+
remove_html(@profile_ext_data['music'])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def profile_movies
|
|
49
|
+
remove_html(@profile_ext_data['movies'])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def profile_television
|
|
53
|
+
remove_html(@profile_ext_data['television'])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def profile_books
|
|
57
|
+
remove_html(@profile_ext_data['books'])
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def profile_heroes
|
|
61
|
+
remove_html(@profile_ext_data['heroes'])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def profile_more_pics
|
|
65
|
+
"http://viewmorepics.myspace.com/index.cfm?fuseaction=user.viewAlbums&friendID=#{@userid}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def profile_more_vids
|
|
69
|
+
"http://vids.myspace.com/index.cfm?fuseaction=vids.channel&channelID=#{@userid}"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def profile_more_play
|
|
73
|
+
"http://music.myspace.com/index.cfm?fuseaction=music.singleplaylist&friendid=#{@userid}&plid="
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def remove_html(str)
|
|
77
|
+
return "" unless str
|
|
78
|
+
str.sub(/<.*?>|<.*?\/>|<\/.*?>/, ' ')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def each_song(doc, &block)
|
|
82
|
+
REXML::XPath.each(doc, '//entry/category[@label="SongUpload" or @label="ProfileSongAdd"]/..', &block)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def compute_realm
|
|
86
|
+
uri = URI::parse(url_for(:action=>:index, :only_path => false))
|
|
87
|
+
uri.path = '/'
|
|
88
|
+
uri.to_s
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<p><h2> MySpace oAuth Delegated Access Demo (also known as the "3-legged scenario" in oAuth lingo) </h2></p>
|
|
4
|
+
<p>This application demonstrates a typical end-user interaction between an OAuth enabled Consumer (this website) and a Service Provider (MySpace)</p>
|
|
5
|
+
<p>The profile and friends information is fetched using the <a href='http://developer.myspace.com/community/myspace/da.aspx'>MySpaceID REST API</a> and is used only for display purposes and is NOT stored in any way by the demo app</p>
|
|
6
|
+
<p><h3><%= link_to("Click here to begin", :action => :start_auth) %></h3></p>
|
|
7
|
+
</body>
|
|
8
|
+
</html>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<!-- Combo-handled YUI CSS files: -->
|
|
4
|
+
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.6.0/build/tabview/assets/skins/sam/tabview.css">
|
|
5
|
+
<!-- Combo-handled YUI JS files: -->
|
|
6
|
+
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&2.6.0/build/imageloader/imageloader-min.js&2.6.0/build/element/element-beta-min.js&2.6.0/build/tabview/tabview-min.js"></script>
|
|
7
|
+
|
|
8
|
+
<style type="text/css">
|
|
9
|
+
body {
|
|
10
|
+
background-color:#C9D0D6;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#MySpaceTabs {
|
|
14
|
+
margin:4em auto;
|
|
15
|
+
min-width:970px;
|
|
16
|
+
width:74.6em;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
|
|
21
|
+
<body class="yui-skin-sam">
|
|
22
|
+
|
|
23
|
+
<% if @profile_data %>
|
|
24
|
+
<div id="MySpaceTabs" class="yui-navset">
|
|
25
|
+
<ul class="yui-nav">
|
|
26
|
+
<li id='profileTab' class="selected"><a href="#tab1"><em>Profile</em></a></li>
|
|
27
|
+
<li id='friendsTab'><a href="#tab2"><em>Friends</em></a></li>
|
|
28
|
+
<li id='albumsTab'><a href="#tab3"><em>Albums</em></a></li>
|
|
29
|
+
</ul>
|
|
30
|
+
<div class="yui-content">
|
|
31
|
+
<div id='profileTabContent'>
|
|
32
|
+
<p><%= image_tag(@profile_data['basicprofile']['image']) %></p>
|
|
33
|
+
<p>Profile URL : <%= link_to(@profile_data['basicprofile']['webUri']) %><p>
|
|
34
|
+
<p>Name: <strong> <%= @profile_data['basicprofile']['name'] %> </strong> </p>
|
|
35
|
+
<p>Gender: <strong> <%= @profile_data['gender'] %> </strong> </p>
|
|
36
|
+
<p>Age: <strong> <%= @profile_data['age'] %> </strong> </p>
|
|
37
|
+
<p>Marital Status: <strong> <%= @profile_data['maritalstatus'] %> </strong> </p>
|
|
38
|
+
<p>City: <strong> <%= @profile_data['city'] %> </strong> </p>
|
|
39
|
+
<p>Postal Code: <strong> <%= @profile_data['postalcode'] %> </strong> </p>
|
|
40
|
+
<p>Region: <strong> <%= @profile_data['region'] %> </strong> </p>
|
|
41
|
+
<p>Country: <strong> <%= @profile_data['country'] %> </strong> </p>
|
|
42
|
+
</div>
|
|
43
|
+
<div id='friendsTabContent'>
|
|
44
|
+
<% for friend in @friends_data['Friends'] %>
|
|
45
|
+
<% link_to(friend['webUri']) do %>
|
|
46
|
+
<img id='<%=friend['name']%>' title='<%= friend['name'] %>' border='0'/>
|
|
47
|
+
<% end %>
|
|
48
|
+
<% end %>
|
|
49
|
+
</div>
|
|
50
|
+
<div id='albumsTabContent'>
|
|
51
|
+
<p>Photos Content Here<p>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<script type="text/javascript">
|
|
57
|
+
var myTabs = new YAHOO.widget.TabView("MySpaceTabs");
|
|
58
|
+
|
|
59
|
+
// Friends Tab Image Loader
|
|
60
|
+
var tabTwoImageGroup = new YAHOO.util.ImageLoader.group('friendsTab', 'mouseover');
|
|
61
|
+
|
|
62
|
+
<% for friend in @friends_data['Friends'] %>
|
|
63
|
+
tabTwoImageGroup.registerSrcImage('<%= friend['name'] %>', '<%= friend['image'] %>');
|
|
64
|
+
<% end %>
|
|
65
|
+
|
|
66
|
+
tabTwoImageGroup.addTrigger('friendsTab', 'focus');
|
|
67
|
+
tabTwoImageGroup.name = 'tab_two_group';
|
|
68
|
+
|
|
69
|
+
// Albums Tab Image Loader
|
|
70
|
+
|
|
71
|
+
</script>
|
|
72
|
+
<% end %>
|
|
73
|
+
</body>
|
|
74
|
+
</html>
|