【问题标题】:How to use LinkedIn's Share API with the Rails Gem如何在 Rails Gem 中使用 LinkedIn 的 Share API
【发布时间】:2012-12-07 13:17:09
【问题描述】:

我正在运行带有 LinkedIn API gem 的 Rails 3:here

我无法让 Share API 按照here 的描述工作

这很好用:

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}):

有什么想法吗?谢谢

【问题讨论】:

    标签: ruby-on-rails xml ruby-on-rails-3 api linkedin


    【解决方案1】:

    你做错了。这是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' } )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-25
      • 1970-01-01
      • 2017-03-16
      • 1970-01-01
      相关资源
      最近更新 更多