Class: Giggly::Rest::Socialize
- Inherits:
-
Object
- Object
- Giggly::Rest::Socialize
- Defined in:
- lib/giggly/rest/socialize.rb
Defined Under Namespace
Classes: InvalidProvider
Constant Summary collapse
- GIGYA_URL =
"http://socialize.api.gigya.com/socialize."
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
-
#disconnect(provider = nil) ⇒ Object
Disconnects the user from the provided network.
-
#friends_info(options = {}) ⇒ Object
- retrieves the friends of the current user Params
enabled_providerscommaseparatedlist of providers to include.
-
#initialize(request) ⇒ Socialize
constructor
Create a new socialize object by passing in a Giggly::Rest::Socialize object or by passing in a hash that will be used to initialize a new Giggly::Rest::Socialize.
-
#publish_user_action(user_action_xml, providers = {}) ⇒ Object
see: http://wiki.gigya.com/030_Gigya_Socialize_API_2.0/030_API_reference/REST_API/socialize.publishUserAction for how to create user_action_xml.
-
#raw_data(provider, fields) ⇒ Object
- get raw data from an individual provider about a user Params
- *
providerthe provider to retrieve the raw data from, only facebook and myspace are currently supported *fieldsa array of provider specific fields to retrieve Returns Hashof the raw data.
- *
-
#send_notification(recipients, subject, body) ⇒ Object
- Sends a notification to a list of friends Params
recipientsa string or array of uids to send the notification to *subjectthe subject line of the notification *bodythe body of the notification, do not use html, Gigya will autolink urls this will post to both facebook and twitter.
-
#session_info(provider, padding_mode = 'PKCS7') ⇒ Object
- get the connection info for a session with a direct api provider this is useful to make calls to a specific provider (not via Socialize) for functions that are currently unsupported by Gigya Socialize Params
providerthe provider to get the connection information for, * possible values are facebook, myspace, twitter, or yahoo *padding_modepadding mode for the AES algorithm used in encryping some of the response parameters * values are PKCS5, PKCS7 or ZEROS PKCS7 will be used as the default See http://wiki.gigya.com/030_Gigya_Socialize_API_2.0/030_API_reference/REST_API/socialize.getSessionInfo on decrypting.
-
#set_status(status, providers = {}) ⇒ Object
- sets the status of a user for the given providers (or all of them if blank) Params
statusthe status to set for the user *providersan optional hash of arrays the has the keys of *enabled_providersan array of provider strings *disabled_providersan array of provider strings.
-
#status=(status) ⇒ Object
- sets the status of a user for all providers Params
statusthe status to set for the user This method will return the status if it is successful, and raise an error on failure Use set status if you want to return the response object Its just in here because we think it looks cool and its convenient.
-
#user_info(providers = {}) ⇒ Object
retrieves user information from gigya, including or excluding providers as indicated.
Constructor Details
#initialize(request) ⇒ Socialize
Create a new socialize object by passing in a Giggly::Rest::Socialize object or by passing in a hash that will be used to initialize a new Giggly::Rest::Socialize. See the rdoc for Request to find details for a new connection hash. A Giggly::Rest::Socialize is used per user (because the Request object is). example:
@socialize = Giggly::Rest::Socialize.new(@connection)
15 16 17 18 |
# File 'lib/giggly/rest/socialize.rb', line 15 def initialize(request) @request = request and return if request.kind_of?(Giggly::Rest::Request) @request = Giggly::Rest::Request.new(request) end |
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
7 8 9 |
# File 'lib/giggly/rest/socialize.rb', line 7 def request @request end |
Instance Method Details
#disconnect(provider = nil) ⇒ Object
Disconnects the user from the provided network.
- Params
networkarray of networks to disconnect from, if emtpy user will be disconnected from all networks Allowed values for network are facebook, myspace, twitter and yahoo.
24 25 26 27 |
# File 'lib/giggly/rest/socialize.rb', line 24 def disconnect(provider = nil) validate_providers! %w[facebook yahoo myspace twitter], provider perform_post :disconnect, :provider => (provider.join(',') if provider) end |
#friends_info(options = {}) ⇒ Object
retrieves the friends of the current user
- Params
enabled_providerscommaseparatedlist of providers to include. (ONLY)disabled_providerscomma separated list of providers to exclude. (NOT)uidslist of users to retrieve.detail_level'basic' or 'extended'
- Returns
ArrayofGiggly::Userobjects
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/giggly/rest/socialize.rb', line 37 def friends_info( = {}) validate_providers! %w[facebook yahoo myspace twitter], [:enabled_providers] params = provider_hash() params[:user_ids], params[:detail_level] = [:uids], [:detailLevel] response = perform_post(:getFriendsInfo, params) friends = [] response['friends']['friend'].each do |friend| friends << Giggly::Friend.new(friend) end friends end |
#publish_user_action(user_action_xml, providers = {}) ⇒ Object
see: http://wiki.gigya.com/030_Gigya_Socialize_API_2.0/030_API_reference/REST_API/socialize.publishUserAction for how to create user_action_xml
88 89 90 91 |
# File 'lib/giggly/rest/socialize.rb', line 88 def publish_user_action(user_action_xml, providers = {}) validate_providers! %w[facebook yahoo], providers[:enabled_providers] perform_post :publishUserAction, {:userAction => user_action_xml}.merge(provider_hash(providers)) end |
#raw_data(provider, fields) ⇒ Object
get raw data from an individual provider about a user
- Params
providerthe provider to retrieve the raw data from, only facebook and myspace are currently supportedfieldsa array of provider specific fields to retrieve
- Returns
Hashof the raw data
56 57 58 59 |
# File 'lib/giggly/rest/socialize.rb', line 56 def raw_data(provider, fields) validate_providers! %w[facebook myspace], provider perform_post :getRawData, {:provider => provider, :fields => fields.join(',')} end |
#send_notification(recipients, subject, body) ⇒ Object
Sends a notification to a list of friends
- Params
recipientsa string or array of uids to send the notification tosubjectthe subject line of the notificationbodythe body of the notification, do not use html, Gigya will autolink urls this will post to both facebook and twitter
99 100 101 102 |
# File 'lib/giggly/rest/socialize.rb', line 99 def send_notification(recipients, subject, body) recipients = recipients.is_a?(Array) ? recipients.join(',') : recipients perform_post :sendNotification, :recipients => recipients, :subject => subject, :body => body end |
#session_info(provider, padding_mode = 'PKCS7') ⇒ Object
get the connection info for a session with a direct api provider this is useful to make calls to a specific provider (not via Socialize) for functions that are currently unsupported by Gigya Socialize
- Params
-
providerthe provider to get the connection information for,- possible values are facebook, myspace, twitter, or yahoo
-
padding_modepadding mode for the AES algorithm used in encryping some of the response parameters- values are PKCS5, PKCS7 or ZEROS PKCS7 will be used as the default See http://wiki.gigya.com/030_Gigya_Socialize_API_2.0/030_API_reference/REST_API/socialize.getSessionInfo on decrypting
70 71 72 73 74 |
# File 'lib/giggly/rest/socialize.rb', line 70 def session_info(provider, padding_mode = 'PKCS7') validate_providers! %w[facebook yahoo myspace twitter], provider # TODO: possibly decrypt response Giggly::SessionInfo.new perform_post(:getSessionInfo, {:provider => provider, :paddingMode => padding_mode}) end |
#set_status(status, providers = {}) ⇒ Object
sets the status of a user for the given providers (or all of them if blank)
- Params
statusthe status to set for the userprovidersan optional hash of arrays the has the keys ofenabled_providersan array of provider stringsdisabled_providersan array of provider strings
110 111 112 113 |
# File 'lib/giggly/rest/socialize.rb', line 110 def set_status(status, providers = {}) validate_providers! %w[facebook yahoo myspace twitter], providers[:enabled_providers] perform_post :setStatus, {:status => status}.merge(provider_hash(providers)) end |
#status=(status) ⇒ Object
sets the status of a user for all providers
- Params
statusthe status to set for the user This method will return the status if it is successful, and raise an error on failure Use set status if you want to return the response object Its just in here because we think it looks cool and its convenient
121 122 123 |
# File 'lib/giggly/rest/socialize.rb', line 121 def status=(status) set_status status end |
#user_info(providers = {}) ⇒ Object
retrieves user information from gigya, including or excluding providers as indicated. default usage includes all providers. returns user.
- Params
providersan optional hash of arrays the has the keys ofenabled_providersan array of provider stringsdisabled_providersan array of provider strings
82 83 84 |
# File 'lib/giggly/rest/socialize.rb', line 82 def user_info(providers = {}) Giggly::User.new perform_post(:getUserInfo, provider_hash(providers)) end |