protected override bool CollectReceiveParametersFromRequest(HttpRequestBase request, Uri targetUrl) { if (targetUrl == null) { throw new ArgumentNullException("targetUrl"); } try { LinkbackTargetUrl = UriHelpers.CreateHttpUrl(targetUrl.ToString()); } catch (UriFormatException) { throw new ArgumentOutOfRangeException("targetUrl"); } if (String.IsNullOrEmpty(request.Form["url"])) { throw new LinkbackReceiveException(String.Format(CultureInfo.InvariantCulture, "Url parameter for {0} not specified", Name)); } LinkbackSourceUrl = UriHelpers.CreateHttpUrl(request.Form["url"]); Title = HttpUtility.HtmlEncode(request.Form["title"]); Excerpt = HttpUtility.HtmlEncode(request.Form["excerpt"]); BlogName = HttpUtility.HtmlEncode(request.Form["blog_name"]); return(true); }
protected override bool CollectReceiveParametersFromRequest(HttpRequestBase request, Uri targetUrl) { byte[] buffer = new byte[request.InputStream.Length]; request.InputStream.Read(buffer, 0, buffer.Length); string request_content = Encoding.UTF8.GetString(buffer); XmlDocument doc = new XmlDocument(); doc.LoadXml(request_content); XmlNode n1 = doc.SelectSingleNode("methodCall/methodName"); if (n1 == null || n1.InnerText != "pingback.ping") { return(false); } XmlNodeList list = doc.SelectNodes("methodCall/params/param/value/string"); if (list.Count != 2) { return(false); } try { LinkbackSourceUrl = UriHelpers.CreateHttpUrl(list[0].InnerText.Trim()); LinkbackTargetUrl = UriHelpers.CreateHttpUrl(list[1].InnerText.Trim()); } catch (UriFormatException) { return(false); } return(true); }