public WebRequest ( Method, method, string url, string postData ) : string | ||
method | Method, | Http Method |
url | string | Full url to the web resource |
postData | string | Data to post in querystring format |
Résultat | string |
private void btnGetTopicPage_Click(object sender, EventArgs e) { txtAPIResponse.Text = ""; _oauth.Token = txtOauth_Access_token.Text; _oauth.TokenSecret = txtOauth_Access_tokenSecret.Text; _oauth.Verifier = txtOauth_verify.Text; string urlHTMLPage = "https://www.linkedin.com/directory/topics-x/"; //string response = _oauth.oAuthWebRequest(oAuthLinkedIn.Method.GET, urlHTMLPage, null); //string response = _oauth.APIWebRequest("GET", urlHTMLPage, null); string response = _oauth.WebRequest(oAuthLinkedIn.Method.GET, urlHTMLPage, null); //HTMLContent htmlForm = new HTMLContent(); //htmlForm.AuthorizeCompleted += new Authorize.AuthorizeCompletedDelegate(authorizeForm_AuthorizeCompleted); //htmlForm.Show(); //htmlForm.Navigate(_authLink); //string response = htmlForm.GetHTML(); txtAPIResponse.Text = response; }
protected void makeApiCall() { if (_faceBookChecked) { StringBuilder fbPost = new StringBuilder(); fbPost.Append("message=" + HttpUtility.UrlEncode(_shareText)); fbPost.Append("&caption=" + HttpUtility.UrlEncode(_postTitle)); fbPost.Append("&link=" + HttpUtility.UrlEncode(_formattedURL)); fbPost.Append("&description=" + HttpUtility.UrlEncode(_shareText)); fbPost.Append("&name=" + HttpUtility.UrlEncode(_postTitle)); fbPost.Append("&scrape=true"); string fbFormattedPost = fbPost.ToString(); //make api call if (_isFacebookGroup == "false") { getPageToken(); } if (_tokenFilter.facebookPageToken != null && _tokenFilter.facebookPageToken != Constants.InvalidIdString) { var url = "https://graph.facebook.com/" + _facebookId + "/feed?access_token=" + _tokenFilter.facebookPageToken; var json = oFB.WebRequest(oAuthFacebook.Method.POST, url, fbFormattedPost); } else if (_tokenFilter.facebookToken != null && _tokenFilter.facebookToken != Constants.InvalidIdString) //no page token received { if (_isFacebookGroup == "true") //no page token received if its a group, post to group { var url = "https://graph.facebook.com/" + _facebookId + "/feed?access_token=" + _tokenFilter.facebookToken; var json = oFB.WebRequest(oAuthFacebook.Method.POST, url, fbFormattedPost); } else if (_isFacebookGroup == "false" && (_tokenFilter.facebookPageToken == null || _tokenFilter.facebookPageToken == Constants.InvalidIdString)) //fallback and post on users personal facebook page { var url = "https://graph.facebook.com/me/feed?access_token=" + _tokenFilter.facebookToken; var json = oFB.WebRequest(oAuthFacebook.Method.POST, url, fbFormattedPost); } else { var url = "https://graph.facebook.com/me/feed?access_token=" + _tokenFilter.facebookToken; var json = oFB.WebRequest(oAuthFacebook.Method.POST, url, fbFormattedPost); } } else { Response.Write("<script>alert('Facebook Authorization Error. Please Authorize Facebook');</script>"); } } if (_linkedInChecked) { //posts to Linkedin via XML. There is a json alternative, but XML seems more stable string encodedTitle = SecurityElement.Escape(_postTitle); //escapes <>'" string encodedText = SecurityElement.Escape(_shareText); //escapes <>'" StringBuilder xmlpost = new StringBuilder(); xmlpost.Append("<?xml version='1.0' encoding='UTF-8'?><post><title>" + encodedTitle + "</title>"); xmlpost.Append("<summary>" + encodedText + "</summary><content>"); xmlpost.Append("<submitted-url>" + HttpUtility.HtmlEncode(_formattedURL) + "</submitted-url><submitted-image-url>" + string.Empty + "</submitted-image-url>"); xmlpost.Append("<title>" + string.Empty + "</title><description>" + _postType + "</description></content></post>"); string formattedLpost = xmlpost.ToString(); if (_tokenFilter.linkedinToken != null) { var requestUrl = "https://api.linkedin.com/v1/groups/" + _linkedinGroupId + "/posts?oauth2_access_token=" + _tokenFilter.linkedinToken; //make api call var xmlreturn = oLinkedIn.WebRequest(oAuthLinkedIn.Method.POST, requestUrl, formattedLpost); } else { Response.Write("<script>alert('Linkedin Authorization Error. Please Authorize Linkedin');</script>"); } } if (_twitterChecked) { if (_tokenFilter.twitterAuthToken != null || _tokenFilter.twitterAuthToken != Constants.InvalidIdString) { oTwitter.TokenSecret = _tokenFilter.twitterSecret; oTwitter.Token = _tokenFilter.twitterAuthToken; //make api call oTwitter.PostMessageToTwitter(_shareText + " " + _formattedURL); } else { Response.Write("<script>alert('Twitter Authorization Error. Please Authorize Twitter');</script>"); } } }