原來要簡單得多,比我在想......(不其八方通?)
主要的一點考慮是:OAuth 2.0用戶不需要簽名,現時,時間戳,授權標題...沒有。
如果您想在LinkedIn上使用sahres API和oAuth2.0發佈...... OAuthbase不是必需的。
只需按照OAuth 2.0驗證流程如下所述: http://developer.linkedin.com/documents/authentication
然後你就可以使用下面的代碼爲出發點:
var shareMsg = new
{
comment = "Testing out the LinkedIn Share API with JSON",
content = new
{
title = "Test post to LinkedIn",
submitted_url = "http://www.somewebsite.com",
submitted_image_url = "http://www.somewebsite.com/image.png"
},
visibility = new
{
code = "anyone"
}
};
String requestUrl = "https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=" + accessToken;
RestClient rc = new RestClient();
RestRequest request = new RestRequest(requestUrl, Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-li-format", "json");
request.RequestFormat = DataFormat.Json;
request.AddBody(shareMsg);
RestResponse restResponse = (RestResponse)rc.Execute(request);
ResponseStatus responseStatus = restResponse.ResponseStatus;
編碼愉快!
restsharp有點酷,但你不需要在這裏使用它。你也可以使用這個代碼... http://stackoverflow.com/a/17988997/17447 – naveen 2013-08-01 08:38:21