2012-01-12 21 views
0

我下載了dquail-LinkedinOauth-f169b1f從C#LinkedIn API dquail的Oauth從當前狀態變更到新<share> API

https://github.com/dquail/LinkedinOauth

我得到它的工作。問題是 - 這個代碼使用其被棄用,限於140個字符

https://developer.linkedin.com/documents/status-update-api

和由共享API,它允許700個字符加上大量的其它特徵已被替換的舊的當前狀態API

https://developer.linkedin.com/documents/share-api

我編輯了代碼以提供新的xml和新的URL - 但出現錯誤。新的代碼是:

private void btnUpdateStatus_Click(object sender, EventArgs e) 
    { 
     try 
     { 
      //string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; 
      //xml += "<current-status>" + txtNewStatus.Text + "</current-status>"; 
      string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><share>"; 
      xml += "<comment>" + txtNewStatus.Text + "</comment><visibility><code>anyone</code></visibility></share>"; 

      //string response = _oauth.APIWebRequest("PUT", "http://api.linkedin.com/v1/people/~/current-status", xml); 
      string response = _oauth.APIWebRequest("PUT", "http://api.linkedin.com/v1/people/~/shares", xml); 
      if (response == "") 
       txtResults.Text += "\n\rYour new status updated. view linkedin for status."; 
     } 
     catch (Exception exp) 
     { 
      txtResults.Text += "\n\rException: " + exp.Message; 
     } 

    } 

我送的XML是:

<?xml version="1.0" encoding="UTF-8" ?> 
    <share> 
    <comment>"Theres a lot of blood, sweat, and guts between dreams and success.", Paul Bryant</comment> 
    <visibility> 
    <code>anyone</code> 
    </visibility> 
    </share> 

我得到的錯誤是:

「遠程服務器返回錯誤:(405)不允許的方法「。

回答

0

您正在使用PUT,但Share API需要POST作爲方法。

405的意思是「你正在使用的HTTP方法這個端點不支持」

至於爲什麼,你不更新當前的狀態,你要添加一個新的共享。 https://developer.linkedin.com/documents/share-api

+0

Kirsten - 謝謝,謝謝,謝謝!我標記你的答案是正確的。 – Bubba 2012-01-13 00:22:38