【问题标题】:c# LinkedIn API dquail Oauth changing from current-status to new <share> apic# LinkedIn API dquail Oauth 从当前状态更改为新的 <share> api
【发布时间】:2012-02-08 19:44:22
【问题描述】:

我从

下载了 dquail-LinkedinOauth-f169b1f

https://github.com/dquail/LinkedinOauth

我让它工作了。问题是 - 此代码使用旧的 current-status api,它已被弃用并限制为 140 个字符

https://developer.linkedin.com/documents/status-update-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) Method Not Allowed。”

【问题讨论】:

    标签: c# api oauth linkedin


    【解决方案1】:

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

    405 表示“您正在使用此端点不支持的 HTTP 方法”

    至于原因,您不是在更新当前状态,而是在添加新共享。 https://developer.linkedin.com/documents/share-api

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-20
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 2011-12-22
      相关资源
      最近更新 更多