timeline.html 2.2 KB
<html>

<body>

<script>

alert("Hello, world!");

</script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://oauth.googlecode.com/svn/code/javascript/oauth.js"></script>
<script src="http://oauth.googlecode.com/svn/code/javascript/sha1.js"></script>
<script type="text/javascript">
$(function(){
    fn_twitterTimeline();
});

function fn_twitterTimeline(){
    var twitterPrm = {
        api: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
        count:100,
        callback:"fn_makedocTwitter",

        consumerKey:"Q4xyL4HBupStqkUf3FaKeDlSL",
        consumerSecret:"xB9ROWLAPlPW7tntBUsFgVZd9qcaCSDDAo5fFCH1qWg7oAwJLO",
        accessToken:"1330868660072660992-0l3jauBmdEP16hXPviH5W1DMS46X9B",
        tokenSecret:"zQjx5xtDHam5SUTSndp7uVqsTpbSJiD4OIKL8IYKg1ZtTSZ"

    }
    var oauthMessage={
        method:"GET",
        action:twitterPrm.api,
        parameters:{
            count: twitterPrm.count,
            callback:twitterPrm.callback,
            oauth_version:"1.0",
            oauth_signature_method:"HMAC_SHA1",
            oauth_consumer_key:twitterPrm.consumerKey,
            oauth_token:twitterPrm.accessToken
        }

    };
    OAuth.setTimestampandNonce(oauthMessage);
    OAuth.SignatureMethod.sign(oauthMessage,{
        consumerSecret: twitterPrm.consumerSecret,
        tokenSecret:twitterPrm.tokenSecret
    });

    var twJsonpath=OAuth.addToURL(oauthMessage.action,oauthMessage.parameters);

    $.ajax({
        type:oauthMessage.method,
        url:twJsonpath,
        dataType:"jsonp",
        jsonp:false,
        cache:true
    });
}

function fn_makedocTwitter(data){
    <DIV id="search"></DIV>
    var timeLine='';
    var text;
    var dateObj=new Data;
    for(var i=0,len=data.length;i<len;i++){
        text=data[i].text;
        text=text.replace(/(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:@&=+$,%#]+)/gi,'<a href="$1">$1</a>');
        text=text.replace(/@(\w+)/gi,'<a href="http://twiiter.com/search?q=%23$1">#$1</a>');
        text.text.replace(/@(\w+)/gi,'<a href="http://twitter.com/$1">@$1</a>');
        timeLine+="<p>"+text+"</p><p>"+dateObj+"</p>";

    }
    $('#div_snstwitter').html(timeLine);
}


</script>


</body>

</html>