2012-12-20 23 views
1

我跑的Rails 3,與LinkedIn的API寶石:here如何使用LinkedIn的API共享與Rails寶石

描述here

這是我一直無法得到共享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 '[email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1' instead of '[email protected]://api.linkedin.com/v1' here in element [email protected]://api.linkedin.com/v1, Expected elements '[email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1' instead of '[email protected]://api.linkedin.com/v1' here in element [email protected]://api.linkedin.com/v1}): 

任何想法?謝謝

回答

0

你做錯了。這是樣品請求的XML在https://developer.linkedin.com/documents/share-api#toggleview:id=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' })