我正在使用此代码并收到错误:
远程服务器返回错误:(401)未经授权。
根据他们的文档,我确实设置了标题。
https://developer.linkedin.com/docs/share-on-linkedin#
我错过了什么?任何帮助将不胜感激。谢谢!
JToken accessCode = myAccessToken;
string requestUrl = "https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=" +
accessCode;
WebRequest request = WebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("x-li-format", "json");
using (var stream = new StreamWriter(request.GetRequestStream()))
{
var shareMsg = new
{
comment = "comment"
content = new
{
title = "title",
submitted_url = "url,
submitted_image_url = "image_url",
description = string.Empty
},
visibility = new { code = "anyone" }
};
string json = JsonConvert.SerializeObject(shareMsg);
stream.Write(json);
stream.Flush();
stream.Close();
}
WebResponse webResponse = request.GetResponse();
Stream dataStream = webResponse.GetResponseStream();
var reader = new StreamReader(dataStream);
string response = reader.ReadToEnd();
答案 0 :(得分:1)
使用Linked In再次注销然后再次验证我的问题。
对于有类似问题的人,您可能需要检查以下内容:
w_share
)其他解决方案: - https://stackoverflow.com/a/41569491/7312674
希望能帮助别人节省一些时间。