API JSON Data:
{"status":200,"users":[{"twitter_screen_name":"mikerbrt","influencers":
[{"twitter_screen_name":"techcrunch","kscore":85.17},
{"twitter_screen_name":"tinucherian","kscore":61.5},
{"twitter_screen_name":"scobleizer","kscore":84.08},
{"twitter_screen_name":"startwerk","kscore":42.12},
{"twitter_screen_name":"mikeschwede","kscore":61.89}]}]}
Script:
$( "#getTweets" ).bind( "click", function() {
var twitterUsername = $( "#twitterUsername" ).val();
var url = "http://api.klout.com/1/soi/influenced_by.json?key=7zcwhzhdp4w45q9fdqw9gqsc" + "&users=" + twitterUsername + "&callback=?";
$.getJSON( url, function( data ) {
for(var i=0; i < data.influencers.length; i++) {
alert(data.influencers[i].kscore);
}
});
});
HTML Data:
<div id="input">
<span>Enter Twitter Username</span>
<input id="twitterUsername" type="text" />
<button id="getTweets">Get Tweets</button>
</div>
<ul></ul>
Required Output: Need to display klout score of influencers
ok, I'm not sure if "Users" property will be treated as an array, or a Single Instance or users, but it will be either :
for(var i=0; i < data.users[0].influencers.length; i++) {
alert(data.users[0].influencers[i].kscore);
}
or
for(var i=0; i < data.users.influencers.length; i++) {
alert(data.users.influencers[i].kscore);
}
depending on how "users" is perceieved HTH. Dave
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With