我正在尝试使用 OAuth v2 向 LinkedIn 发布共享 - 我已正确获得授权并拥有适当的访问密钥。
发布到:https ://api.linkedin.com/v1/people/~/shares?oauth2_access_token=(访问令牌)
共享 XML:
> <?xml version="1.0" encoding="UTF-8"?> <share> <content> <title>White
> Cobalt Ltd</title> <description>Test</description>
> <submitted-url>https://www.whitecobalt.com/</submitted-url> </content>
> <visibility> <code>anyone</code> </visibility> </share>
要发布的代码(C#):
RestClient oRC = new RestClient();
RestRequest oRequest = new RestRequest(sURL, Method.POST);
oRequest.AddHeader("Content-Type", "application/xml");
oRequest.AddHeader("x-li-format", "xml");
oRequest.RequestFormat = DataFormat.Xml;
oRequest.AddBody(xml);
RestResponse oResponse = (RestResponse)oRC.Execute(oRequest);
if ((oResponse.ResponseStatus == ResponseStatus.Completed) && (oResponse.StatusCode == HttpStatusCode.Accepted))
{
... success
}
当我使用 API 控制台(https://apigee.com/console/linkedin)时,它运行良好,但是当我尝试通过代码运行它时(据我所知,它正在做完全相同的事情)我得到以下错误:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<status>400</status>
<timestamp>1373465292361</timestamp>
<request-id>FQEJFQOL6U</request-id>
<error-code>0</error-code>
<message>Couldn't parse share document: error: The document is not a share@http://api.linkedin.com/v1: document element local name mismatch expected share got String</message>
</error>