public string APIWebRequest(string method, string url, string postData)
{
Uri uri = new Uri(url);
string nonce = this.GenerateNonce();
string timeStamp = this.GenerateTimeStamp();
string outUrl, querystring;
//Generate Signature
string sig = this.GenerateSignature(uri,
this.ConsumerKey,
this.ConsumerSecret,
this.Token,
this.TokenSecret,
method,
timeStamp,
nonce,
null,
out outUrl,
out querystring);
HttpWebRequest webRequest = null;
webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
webRequest.Method = method;
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.AllowWriteStreamBuffering = true;
webRequest.PreAuthenticate = true;
webRequest.ServicePoint.Expect100Continue = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
webRequest.Headers.Add("Authorization", "OAuth realm=\"http://api.linkedin.com/\",oauth_consumer_key=\"" + this.ConsumerKey + "\",oauth_token=\"" + this.Token + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(sig) + "\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonce + "\",oauth_verifier=\"" + this.Verifier + "\", oauth_version=\"1.0\"");
if (postData != null)
{
byte[] fileToSend = Encoding.UTF8.GetBytes(postData);
webRequest.ContentLength = fileToSend.Length;
Stream reqStream = webRequest.GetRequestStream();
reqStream.Write(fileToSend, 0, fileToSend.Length);
reqStream.Close();
}
string returned = WebResponseGet(webRequest);
return returned;
}