【发布时间】:2016-05-20 15:57:34
【问题描述】:
我正在尝试通过 REST API 共享我的内容。 后端 - Ruby/Rails
最初,我尝试使用 gem 'linkedin'、'linkedin-oauth2',但出现错误“无法发布共享”
gem '链接'
consumer_options = {
:request_token_path => "/uas/oauth/requestToken?scope=r_basicprofile+rw_nus",
:access_token_path => "/uas/oauth/accessToken",
:authorize_path => "/uas/oauth/authorize",
:api_host => "https://api.linkedin.com",
:auth_host => "https://www.linkedin.com"
}
client = LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret', consumer_options)
client.authorize_from_access(token, token_secret)
client.add_share(:comment => 'test gempost')
gem 'linkedin-oauth2'
api = LinkedIn::API.new(access_token)
api.add_share(content: "hi")
然后我使用 HTTParty 遵循此处 https://developer.linkedin.com/docs/share-on-linkedin 的说明,但再次收到错误“访问发布共享被拒绝”。
data = { comment: message, visibility: {code: 'anyone'} }
response = HTTParty.post("https://api.linkedin.com/v1/people/~/shares?format=json",
headers: { 'Content-Type' => 'application/json'},
query: {oauth2_access_token: linkedin_identity.token},
body: data.to_json)
我已授予我的应用程序的所有权限 - 出现此类错误的原因是什么? 有没有人有过通过 API 发布到 Linkedin 的经验?
【问题讨论】:
-
你的错误解决了吗。您能否在此处发布该解决方案,因为我面临同样的问题,所以它可能对我有所帮助。谢谢
标签: linkedin