1

我正在使用 LinkedIn API gem 运行 Rails 3:这里

我一直无法让 Share API 像这里描述的那样工作

这工作正常:

response = client.add_share(:comment => 'new share API')

这失败了:

  response = client.add_share(:comment => 'new share API', :title => 'Linkedin Share API', :url => 'http://developer.linkedin.com/docs/DOC-1212', :image_url => 'http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg')

错误:

LinkedIn::Errors::GeneralError ((400): Invalid xml {Expected elements 'post-network-update@http://api.linkedin.com/v1 id@http://api.linkedin.com/v1 visibility@http://api.linkedin.com/v1 comment@http://api.linkedin.com/v1 attribution@http://api.linkedin.com/v1 content@http://api.linkedin.com/v1 private-message@http://api.linkedin.com/v1 share-target-reach@http://api.linkedin.com/v1' instead of 'image-url@http://api.linkedin.com/v1' here in element share@http://api.linkedin.com/v1, Expected elements 'post-network-update@http://api.linkedin.com/v1 id@http://api.linkedin.com/v1 attribution@http://api.linkedin.com/v1 content@http://api.linkedin.com/v1 private-message@http://api.linkedin.com/v1 share-target-reach@http://api.linkedin.com/v1' instead of 'url@http://api.linkedin.com/v1' here in element share@http://api.linkedin.com/v1}):

有任何想法吗?谢谢

4

1 回答 1

0

你这样做是错的。这是https://developer.linkedin.com/documents/share-api#toggleview:id=xml中示例请求的 XML

  <share>
  <comment>Check out the LinkedIn Share API!</comment>
  <content>
    <title>LinkedIn Developers Documentation On Using the Share API</title>
    <description>Leverage the Share API to maximize engagement on user-generated content on LinkedIn</description>
    <submitted-url>https://developer.linkedin.com/documents/share-api</submitted-url>
    <submitted-image-url>http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png</submitted-image-url> 
  </content>
  <visibility> 
    <code>anyone</code> 
  </visibility>
</share>

因此,根据示例请求,请求应该看起来像这样:

response = client.add_share(:comment => 'Sample Job',
                            :content => { :title => 'LinkedIn Developers Documentation On Using the Share API', :description => 'Leverage the Share API to maximize engagement on user-generated content on LinkedIn', :'submitted-url' => 'https://developer.linkedin.com/documents/share-api', :'submitted-image-url' => 'http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png' } )
于 2014-07-18T17:19:58.237 回答