2011-10-19 6 views
0

내 문제는 Twitter 푸시 티커가 페이지의 절대 바닥 글로 배치 된 사이트의 출시를 상속 한 것입니다. 정부는 사료에 retweets이나 @mentions를 포함시키지 않기로 결정했다. 피드가 Atom RSS를 통해 집계되는 것을 볼 수 있습니다. 나는 C# 코드에서 검색어와 트위터 URL을 변경하려고 시도했으며 전체 사이트가 충돌합니다.Twitter API Atom Aggregator with C#

불행히도 C#에서는 완전히 익숙하지 않기 때문에이 코드를 수정할 수있는 능력은 기껏해야 제한적입니다. 웹 사이트로 구성되어

등 머리글, 바닥 글, 트위터 바, 또한

을 위해 포함, 사이트에 대한 예상 발사는 COB에서 오늘 저녁은 처음이 아닌에서 이렇게 다른 플러그인을 제도입니다 정말 옵션.

시세가 (이 여기에 표시 할 수 있도록 코드가 개폐 주석 괄호가 누락)이있는 페이지로 호출됩니다

com.omniupdate.div label="ticker" path="/z-omniupdate/fakes/bfeo/2012/ticker.html"  
bf2012:ticker runat="server"  
/com.omniupdate.div 

CSS의는 다음과 같습니다

#ticker{ 
    width: 100%; 
    height: 43px; 
    border-top: 1px solid #939241; 
    background: #bdcc2a url('/bfeo/2012/img/tweet-bg.gif') 0 0 repeat-x; 
    background: -moz-linear-gradient(#bdcc2a, #a9b625); 
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#a9b625), to(#e4c595)); 
    background: -webkit-linear-gradient(#bdcc2a, #a9b625); 
    background: -o-linear-gradient(#bdcc2a, #a9b625); 
    position:fixed; 
    z-index: 1000; 
    bottom: 0; 
} 
    #ticker p{ 
     font-size: 15px; 
     color: #fff; 
     text-transform: uppercase; 
     float: left; 
     line-height: 43px; 
     margin-right: 10px; 
    } 
.ticker-engage { 
    list-style: none; 
    padding: 0; 
    margin: 8px 0 0 0; 
    width: 108px; 
    height: 28px; 
    float: left; 
} 
    .ticker-engage li{ 
     display: inline;  
    } 
    .ticker-engage li a{ 
     height: 28px; 
     width: 28px; 
     text-indent: -9999px; 
     float: left; 
     margin: 0 2px 0 0; 
    } 
    .ticker-engage li a.twitter{ 
     background: url('/bfeo/2012/img/twitter-sm.png') 0 0 no-repeat; 
    } 
    .ticker-engage li a.facebook{ 
     background: url('/bfeo/2012/img/facebook-sm.png') 0 0 no-repeat; 
    } 
    .ticker-engage li a.youtube{ 
     background: url('/bfeo/2012/img/youtube-sm.png') 0 0 no-repeat; 
    } 
#tweetlist{ 
    list-style: none; 
    padding: 7px 20px 0 20px; 
    height: 36px; 
    width: 666px; 
    float: left; 
    background: url('/bfeo/2012/img/tweet-bg.gif') 0 0 repeat-x; 
    background: -moz-linear-gradient(#aab726, #98a322); 
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#aab726), to(#98a322)); 
    background: -webkit-linear-gradient(#aab726, #98a322); 
    background: -o-linear-gradient(#aab726, #98a322); 
    font-size: 12px; 
} 
    #tweetlist li{ 
     display: inline;  
    } 
    #tweetlist li a:link, #tweetlist li a:visited{ 
     color: #fff; 
     text-decoration: none; 
     font-weight: normal; 
    } 
    #tweetlist li a:hover, #tweetlist li a:focus{ 
     text-decoration: underline; 
    } 
    #tweetlist li span{ 
      color: #ffe400; 
    } 

시세 의 .ascx :

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ticker.ascx.cs" Inherits="bf_controls_ticker" %> 
<div id="ticker"> 
    <div class="wrapper clearfix"> 
     <p>Engage with us</p> 
     <ul class="ticker-engage"> 
      <li><a class="facebook" target="_blank" href="http://www.facebook.com/booththinking"> 
       Facebook</a></li> 
      <li><a class="twitter" target="_blank" href="http://twitter.com/booththinking">Twitter</a></li> 
      <li><a class="youtube" target="_blank" href="http://www.youtube.com/user/BoothThinking"> 
       Youtube</a></li> 
     </ul> 
     <form id="form1" runat="server"> 
     <div> 
      <ul id="tweetlist"> 
       <asp:Literal ID="Literal1" runat="server"></asp:Literal> 
      </ul> 
     </div> 
     </form> 
    </div> 
</div> 

ticker.ascx.cs

using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml; 
using System.Text; 

public partial class bf_controls_ticker : System.Web.UI.UserControl 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     XmlDocument doc = new XmlDocument(); 
     doc.LoadXml(HttpGet("http://search.twitter.com/search.atom?q=booththinking")); 
     XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); 
     ns.AddNamespace("at", "http://www.w3.org/2005/Atom"); 
     ns.AddNamespace("twitter", "http://api.twitter.com/"); 
     XmlNodeList entries = doc.DocumentElement.SelectNodes("//at:entry", ns); 
     //Response.Write(entries.Count); 
     StringBuilder sb = new StringBuilder(); 
     foreach (XmlNode node in entries) 
     { 
      sb.Append(String.Format("<li><span>{2}:</span> <a href=\"{0}\">{1}</a></li>", node.ChildNodes[2].Attributes["href"].Value, node.ChildNodes[3].InnerText, node.LastChild.FirstChild.InnerText.Split(' ')[0])); 
     } 
     Literal1.Text = sb.ToString(); 
    } 

    private string HttpGet(string URI) 
    { 
     System.Net.WebRequest req = System.Net.WebRequest.Create(URI); 

     System.Net.WebResponse resp = req.GetResponse(); 
     if (resp == null) return null; 

     System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()); 
     string responsexml = sr.ReadToEnd().Trim(); 
     sr.Close(); 

     return responsexml; 
    } 
} 

답변

1

정확하게 이해한다면 건너 뛰려는 패턴의 문자열을 확인할 수 있습니다.

foreach (XmlNode node in entries) 
{ 
    var content = node.SelectSingleNode("at:content", ns).InnerText; 

    if(!content.ToLower().Contains("@somename")) 
    { 
     sb.Append(String.Format("<li><span>{2}:</span> <a href=\"{0}\">{1}</a></li>", node.ChildNodes[2].Attributes["href"].Value, node.ChildNodes[3].InnerText, node.LastChild.FirstChild.InnerText.Split(' ')[0])); 
    } 
} 

일치하는 더 복잡한 패턴 정규 표현식을 살펴 가지고 각 루프 같은 것을 시도 당신에