简体   繁体   English

C#LinkedIn API dquail Oauth从当前状态更改为新状态 <share> api

[英]c# LinkedIn API dquail Oauth changing from current-status to new <share> api

I downloaded the dquail-LinkedinOauth-f169b1f from 我从以下位置下载了dquail-LinkedinOauth-f169b1f

https://github.com/dquail/LinkedinOauth https://github.com/dquail/LinkedinOauth

I got it working. 我知道了 Problem is - this code uses the old current-status api which is deprecated and limited to 140 characters 问题是-此代码使用旧的current-状态api,该API已弃用,并且限制为140个字符

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

and has been replaced by the share api which allows 700 characters plus a lot of other features 并已由共享API取代,该API允许700个字符以及许多其他功能

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

I edited the code to provide the new xml and the new URL - but I get an error. 我编辑了代码以提供新的xml和新的URL-但出现错误。 The new code is: 新的代码是:

    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;
        }

    }

The XML I am sending is: 我发送的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>

the error I get is: 我得到的错误是:

"The remote server returned an error: (405) Method Not Allowed." “远程服务器返回错误:(405)不允许的方法。”

You're using PUT, but the Share API requires POST as the method. 您正在使用PUT,但是Share API需要POST作为方法。

405 means "You're using an HTTP method this endpoint doesn't support" 405的意思是“您正在使用此终结点不支持的HTTP方法”

As far as why, you're not updating the current status, you're adding a new share. 至于为什么,您不更新当前状态,而是要添加新的共享。 https://developer.linkedin.com/documents/share-api https://developer.linkedin.com/documents/share-api

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM