Class: LinkedIn::ShareAndSocialStream
- Inherits:
-
APIResource
- Object
- APIResource
- LinkedIn::ShareAndSocialStream
- Defined in:
- lib/linked_in/share_and_social_stream.rb
Overview
Share and Social Stream APIs
LinkedIn’s v2 API adherence to the documentation is shaky at best. Several of the calls simply don’t work if you, e.g., pass the URN in as a path element for a resource - you have to use the ids= format w/ a single URN. Or sometimes passing in an “actor” parameter in the request body simply doesn’t work, and you have to pass it in as a URL parameter. What you see in this file is the result of trial-and-error getting these endpoints to work, and the inconsistency is usually a result of either misunderstanding the docs or the API not working as advertised. It’s also a bit unclear when the API wants an activity URN vs, e.g., an article URN. Caveat emptor.
[(contribute here)](github.com/mdesjardins/linkedin-v2)
Instance Method Summary collapse
-
#comment(options = {}) ⇒ Object
Adds a comment to a specific post.
-
#comments(options = {}) ⇒ Object
Retrieves the comments for a specific post.
-
#get_share(options = {}) ⇒ Object
Retrieve Share by ID.
-
#get_social_actions(share_urns) ⇒ Object
Retrieve a Summary of Social Actions.
-
#like(options = {}) ⇒ Object
Likes a specific share or comment.
-
#likes(options = {}) ⇒ LinkedIn::Mash
Retrieves the likes for a specific post.
-
#migrate_update_keys(update_keys) ⇒ Object
Migrate from Update Keys to Share URNs.
-
#share(options = {}) ⇒ LinkedIn::Mash
Create one share from a person, organization, or organizationBrand.
-
#shares(options = {}) ⇒ LinkedIn::Mash
Retrieve shares from a person, organization, or organizationBrand.
-
#unlike(options = {}) ⇒ Object
Un-likes a previously liked share or comment.
Methods inherited from APIResource
#id_to_urn, #initialize, #urn_to_id
Constructor Details
This class inherits a constructor from LinkedIn::APIResource
Instance Method Details
#comment(options = {}) ⇒ Object
Adds a comment to a specific post.
Permissions:
urn:li:article:123)
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/linked_in/share_and_social_stream.rb', line 148 def comment( = {}) urn = .delete(:urn) actor = .delete(:actor) = .delete(:message) parent_comment = .delete(:parent_comment) body = { actor: actor, message: { text: } } body.merge!(parentComment: parent_comment) if parent_comment path = "/socialActions/#{urn}/comments" post(path, MultiJson.dump(body), 'Content-Type' => 'application/json') end |
#comments(options = {}) ⇒ Object
Retrieves the comments for a specific post.
urn:li:article:123)
130 131 132 133 134 |
# File 'lib/linked_in/share_and_social_stream.rb', line 130 def comments( = {}) urn = .delete(:urn) path = "/socialActions/#{urn}/comments" get(path, ) end |
#get_share(options = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/linked_in/share_and_social_stream.rb', line 43 def get_share( = {}) id = .delete(:id) path = "/shares/#{id}" get(path, ) end |
#get_social_actions(share_urns) ⇒ Object
77 78 79 80 |
# File 'lib/linked_in/share_and_social_stream.rb', line 77 def share_urns path = '/socialActions' get(path, ids: share_urns) end |
#like(options = {}) ⇒ Object
Likes a specific share or comment.
This object should be a sub-entity of the top-level share indicated in the request URL, and should be represented as an URN either of format urn:li:share:id represented by a urn:li:person:id or urn:li:organization:id URN.
105 106 107 108 109 |
# File 'lib/linked_in/share_and_social_stream.rb', line 105 def like( = {}) urn = .delete(:urn) path = "/socialActions/#{urn}/likes" post(path, MultiJson.dump(), 'Content-Type' => 'application/json') end |
#likes(options = {}) ⇒ LinkedIn::Mash
Retrieves the likes for a specific post.
89 90 91 92 93 |
# File 'lib/linked_in/share_and_social_stream.rb', line 89 def likes( = {}) urn = .delete(:urn) path = "/socialActions/#{urn}/likes" get(path, ) end |
#migrate_update_keys(update_keys) ⇒ Object
Migrate from Update Keys to Share URNs
168 169 170 171 |
# File 'lib/linked_in/share_and_social_stream.rb', line 168 def migrate_update_keys update_keys path = '/activities' get(path, ids: update_keys) end |
#share(options = {}) ⇒ LinkedIn::Mash
Create one share from a person, organization, or organizationBrand.
Permissions:
1.) For personal shares, you may only post shares as the authorized member.
2.) For organization shares, you may only post shares as an organization for which the
authorized member is an administrator.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/linked_in/share_and_social_stream.rb', line 61 def share( = {}) path = '/shares' defaults = { distribution: { linkedInDistributionTarget: { visibleToGuest: true } } } post(path, MultiJson.dump(defaults.merge()), 'Content-Type' => 'application/json') end |
#shares(options = {}) ⇒ LinkedIn::Mash
Retrieve shares from a person, organization, or organizationBrand.
Permissions:
1.) For personal shares, you may only retrieve shares for the authorized members.
2.) For organization shares, you may only retrieve shares for organizations for which the
authorized member is an administrator.
33 34 35 36 37 |
# File 'lib/linked_in/share_and_social_stream.rb', line 33 def shares( = {}) urn = .delete(:urn) path = "/shares?q=owners&owners=#{urn}" get(path, ) end |
#unlike(options = {}) ⇒ Object
Un-likes a previously liked share or comment.
117 118 119 120 121 122 |
# File 'lib/linked_in/share_and_social_stream.rb', line 117 def unlike( = {}) urn = .delete(:urn) actor = .delete(:actor) path = "/socialActions/#{urn}/likes/#{actor}?actor=#{CGI::escape(actor)}" delete(path, MultiJson.dump(), 'Content-Type' => 'application/json') #options) end |